﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
 	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<base id="href" href="<%=basePath%>">
<link rel="stylesheet" type="text/css" href="static/js/jquery-easyui-1.5.3/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="static/js/jquery-easyui-1.5.3/themes/icon.css"/>
<script type="text/javascript" src="static/js/jquery-easyui-1.5.3/jquery.min.js"></script>
<script type="text/javascript" src="static/js/jquery-easyui-1.5.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="static/js/jquery-easyui-1.5.3/locale/easyui-lang-zh_CN.js"></script>
<script language="javascript" type="text/javascript"src="static/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="static/js/consignhandle/checkBox.js"></script>
<script type="text/javascript"src="static/js/common/tooltip.js"></script>

<title>修改内贸托单</title>
<style type="text/css">
	.validatebox-text{width:50px;}
	#volume{width:90px;}
	.tit,.tiv{font-size:20px;font-weight:900;padding-left: 3px;}
	.tit{color:#5FC3FF; }
	.tiv{color:red;}
</style>
</head>
<body>
	<form id="form1" name="form1" method="post">
    	<div style="width:100%;text-align:center;height:40px;line-height:40px;">
        	<b class="tit">进仓编号:</b><b id="billCode" name="billCode" class="tiv">${pd.billCode}</b>
        	<b class="tit">提单编号 :</b><b class="tiv">${pd.billCode}</b>
        </div>
        <div style="width:100%;border-bottom:1px solid #000000;" id="bigDiv1">
            <table style="width:100%;">
                <tr>
                    <td style="width:12%;text-align:right;">
                     	 销售人员<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="salesManName" id="salesManName">
                    </td>
                    <td style="width:12%;text-align:right;">
                       	 所属部门<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="sales_man_dep_show" id="salesManDepShow" disabled="disabled"/>
                        <input type="hidden" name="sales_man_dep" id="salesManDep"/>
                        <input type="hidden" name="trade_flag" id="tradeFlag" value="2"/>
                    </td>
                    <td style="width:12%;text-align:right;">
                      	  所属区域<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" id="salesManAgentShow" name="sales_man_agent_show" disabled="disabled">
                        <input type="hidden" id="salesManAgent" name="sales_man_agent">
                    </td>
                </tr>
                <tr>
                    <td style="width:12%;text-align:right;">
                    	托运人全称<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="agency_man" id="agencyMan"/>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	货主<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="agency_contact" id="agencyContact"/>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	托运人自编号<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="agency_self_no" id="agency_self_no"/>
                    </td>
                </tr>
                <tr>
                    <td style="width:12%;text-align:right;">
                    	客户类别<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" id="client_type" disabled="disabled"/>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	付款方式<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" id="pay_way" disabled="disabled"/>
                    </td>
                	<td style="width:12%;text-align:right;">
                    	托运人联系人<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="contact" id="contact"/>
                    </td>
                </tr>
                <tr>
                    <td style="width:12%;text-align:right;">
                    	托运人联系方式<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="contact_info" id="contact_info"/>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	箱主<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="box_master" name="box_master">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	贸易类型<font color="#FF0000">*</font>
                    </td>
                    <td style="padding-left:10px;text-align:left;">
                    	<select id="trade_mode" name="trade_mode" style="width:153px;">
                    		<option value=""></option>
                    		<option value="0">沿江内贸</option>
                    		<option value="1">沿海内贸</option>
                    	</select>
                    </td>
                </tr>
                <tr>
                <td style="width:12%;text-align:right;">
                    	货代客服<font color="#FF0000"></font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="forwarder_man" name="forwarder_man">
                    </td>
                <td style="width:12%;text-align:right;">
                    	提单号<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="bol_code" id="bolCode" value="NULL"/>
                    </td>
                </tr>
            </table>
        </div>
        <div style="width:100%;border-bottom:1px solid #000000;" id="bigDiv2">
        	<div style="text-align:center;width:100%;height:10px;"></div>
            <table style="width:100%;">
            	<tr>
                    <td style="width:12%;text-align:right;">
                    	发货人(SHIPPER)<font color="#FF0000">*</font><br>
                    	<input type="text" id="search_shipper" name="search_shipper">
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<textarea style="width:200px;height:150px;" id="shipper" name="shipper"></textarea>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	收货人(CONSIGNEE)<font color="#FF0000">*</font><br>
                    	<input type="text" id="search_consignee" name="search_consignee">
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<textarea style="width:200px;height:150px;" id="consignee" name="consignee"></textarea>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	通知人(NOTIFY)<font color="#FF0000">*</font><br>
                    	<input type="text" id="search_notice_man" name="search_notice_man">
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<textarea style="width:200px;height:150px;" id="notice_man" name="notice_man"></textarea>
                    </td>
                </tr>
                <tr>
                    <td style="width:12%;text-align:right;">
                    	装运唛头(MARK)<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<textarea style="width:200px;height:150px;" id="goods_sign" name="goods_sign">N/M</textarea>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	货物描述(DESCRIPTION)<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<textarea style="width:200px;height:150px;" id="goods_english_name" name="goods_english_name"></textarea>
                    </td>
                    <td style="width:12%;text-align:right;height:150px;line-height:20px">
						装运港<font color="#FF0000">*</font><br><br>
						卸货港<font color="#FF0000" id="suf">*</font><br><br>
                    	交货地<font color="#FF0000">*</font><br><br>
						中文品名<font color="#FF0000">*</font>
                   </td>
                   <td style="width:21%;padding-left:10px;text-align:left;height:150px;line-height:20px">
                    	<input type="text" id="load_harbour" name="load_harbour"><br><br>
                    	<input type="hidden" id="load_harbour_milage" name="load_harbour_milage"/>
                    	<input type="text" id="unload_harbour" name="unload_harbour"><br><br>
                    	<input type="hidden" id="unload_harbour_milage" name="unload_harbour_milage"/>
                    	<input type="text" id="stop_harbour" name="stop_harbour"><br><br>
                    	<input type="text" id="goods_chinese_name" name="goods_chinese_name" onblur="isDangerous(this.value)">
                   </td>
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
                    	可否分批<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="partial_flag" name="partial_flag">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	可否转船<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="change_ship_flag" name="change_ship_flag">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	提单类型<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="bol_type" name="bol_type">
                    	<input type="hidden" id="bolType_Id" name="bolType_Id">
                    </td>
                </tr>
            	<tr>
                    <td style="width:12%;text-align:right;">
                    	货物件数及单位<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="goods_pkgs" name="goods_pkgs" style="width:50px">
                    	<input type="text" id="goods_package" name="goods_package" style="width:60px">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	货物毛重<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="goods_weight" name="goods_weight" style="width:130px;"> KGS
                    </td>
                    <td style="width:12%;text-align:right;">
                    	体积<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="goods_measurment" name="goods_measurment" style="width:130px;"> CBM
                    </td>
                </tr>
                <tr id="t1">
                	<td style="width:12%;text-align:right;">
                    	预计装船时间<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="load_date" name="load_date" class="Wdate" readonly="readonly" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',skin:'whyGreen'})">
                    </td>
                	<td style="width:12%;text-align:right;">
                		最迟交货期<font color="#FFFFFF">*</font>
                	</td>
                	<td style="width:21%;padding-left:10px;text-align:left;">
                		<input type="text" id="latestDateOfShipment" name="latestDateOfShipment" class="Wdate" readonly="readonly" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',skin:'whyGreen'})">
                	</td>
                	<td style="width:12%;text-align:right;">
                    	货源<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="supply_of_goods" id="supply_of_goods"/>
                    </td>
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
                    	箱型确定<font color="#FF0000">*</font>
                    </td>
                    <td style="padding-left:10px;text-align:left;" colspan="3">
                    	<input type="text" id="box_type" name="box_type" style="width:97%" readonly="readonly">
                    	<input type="hidden" id="big_box" name="big_box" readonly="readonly">
                    	<input type="hidden" id="small_box" name="small_box" readonly="readonly">
                    	<input type="hidden" id="big_boxh" name="big_boxh" readonly="readonly">
                    	<input type="hidden" id="bigbig_box" name="bigbig_box" readonly="readonly">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	是否指定用箱<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="specified_box" name="specified_box">
                    </td>
                </tr>
                <tr>
                    <td style="width:12%;text-align:right;">
                    	<span id="s6">
                    		箱号<font color="#FFFFFF">*</font>
                    	</span>
                    </td>
                	<td style="padding-left:10px;text-align:left;" colspan="3">
                		<input type="text" id="box_no" name="box_no" style="width:97%;" readonly="readonly">
                		<input type="hidden" id="hbox_type" name="hbox_type">
                	</td>
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
                    	客户免堆期<font color="#FFFFFF">*</font>
                    </td>
                    <td style="padding-left:10px;text-align:left;width:55%;" colspan="3">
                    	<input type="text" id="free_day_remark" name="free_day_remark">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	货物种类<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="goods_type" name="goods_type">
                    </td>
                </tr>
                <tr id="tr9" style="display:none">
                    <td style="width:12%;text-align:right;">
                    	<span id="s2" style="display:none">冷藏温度<font color="#FF0000">*</font></span>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<div style="display:none" id="div2">
                    		<input type="text" id="cold_rem" name="cold_rem">
                    	</div>
                    </td>
                	<td style="width:12%;text-align:right;">
                    	<span id="s3" style="display:none">危险品名<font color="#FF0000">*</font></span>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<div style="display:none" id="div3">
                    		<input type="text" id="dangerous_name" name="dangerous_name" style="display:none">
                    	</div>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	<span id="s5" style="display:none">危险品类别<font color="#FF0000">*</font></span>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<div style="display:none" id="div7">
                    		<input type="text" id="dangerous_type" name="dangerous_type" readonly="readonly">
                    	</div>
                    </td>
                </tr>
                <tr id="tr8" style="display:none">
                	<td style="width:12%;text-align:right;">
                    	危险品等级<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="dangerous_level" name="dangerous_level" readonly="readonly">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	国内代码<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="internal_code" name="internal_code" readonly="readonly">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	国际代码<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="international_code" name="international_code" readonly="readonly">
                    </td>
                </tr>
            </table>
        </div>
        <div style="width:100%;border-bottom:1px solid #000000;"  id="bigDiv3">
        	<div style="text-align:center;width:100%;height:10px;"></div>
            <table style="width:100%;">
            	<tr>
                	<td style="width:12%;text-align:right;">
                    	价格来源<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="price_source" name="price_source">
                    </td>
                   	<td style="width:12%;text-align:right;">
                   		报价编号<font color="#FFFFFF">*</font>
                   	</td>
                   	<td style="width:21%;padding-left:10px;text-align:left;">
                   		<input type="text" id="enquiry_no" name="enquiry_no" disabled="disabled">
                   	</td>
                    <td style="width:12%;text-align:right;" rowspan="2">
                    	价格备注<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;" rowspan="2">
                    	<textarea id="price_remarks" name="price_remarks" style="width:153px;height:80px;"></textarea>
                    </td>
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
                    	船公司订舱价格<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="price_amount" name="price_amount">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	其他运费条款<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="fee_item" name="fee_item">
                    </td>
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
                    	价格开始时间<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="price_start_date" name="price_start_date" class="Wdate" readonly="readonly" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'priceEndDate\')}',dateFmt:'yyyy-MM-dd',skin:'whyGreen'})">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	价格停止时间<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="price_end_date" name="price_end_date" class="Wdate" readonly="readonly" onclick="WdatePicker({minDate:'#F{$dp.$D(\'priceStartDate\')}',dateFmt:'yyyy-MM-dd',skin:'whyGreen'})">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	运输条款<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="transport_item" name="transport_item">
                    </td>
                </tr>
                <tr>
                    <td style="width:12%;text-align:right;">
                    	运费条款<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="carriage_type" name="carriage_type">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	<span id="s4" style="display:none">第三地名称<font color="#FF0000">*</font></span>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<div id="div4" style="display:none">
                    		<input type="text" id="third_place" name="third_place">
                    	</div>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	是否买舱<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<select id="isBuyClass" name="isBuyClass">
                    		<option value="1">是</option>
                    		<option value="2" selected="selected">否</option>
                    	</select>
                    </td>
                </tr>
            </table>
        </div>
        <div style="width:100%;border-bottom:1px solid #000000;"  id="bigDiv4">
        	<div style="text-align:center;width:100%;height:10px;"></div>
            <table style="width:100%;">
                <tr>
                    <td style="width:12%;text-align:right;">
                    	是否安排拖车<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<select id="is_trailer" name="is_trailer">
                    		<option value="0"></option>
                    		<option value="1">自拖车</option>
                    		<option value="2">委托拖车</option>
                    	</select>
                    	<a id="trailerInfo" style="display:none">编辑拖车信息</a>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	代办保险<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="insurance" name="insurance">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	<span id="s7" style="display:none">保险名称</span>
                    </td>
        			<td style="width:21%;padding-left:10px;text-align:left;">
        				<input type="text" id="bxmc" name="bxmc" style="display:none">
        			</td>
                </tr>
                <tr id="tr11" style="display:none">
               		<td style="width:12%;text-align:right;">
        				<span id="s8" style="display:none">保险金额</span>
        			</td>
        			<td style="width:21%;padding-left:10px;text-align:left;">
        				<input type="text" id="bxje" name="bxje" style="display:none">
        			</td>
               		<td style="width:12%;text-align:right;">保险比率</td>
        			<td style="width:21%;padding-left:10px;text-align:left;">
        				<input type="text" id="bxbl" name="bxbl">
        			</td>
        			<td style="width:12%;text-align:right;">保险备注</td>
        			<td style="width:21%;padding-left:10px;text-align:left;">
        				<input type="text" id="bz" name="bz">
        			</td>
               </tr>
               <tr style="display:none" id="trailerTr">
                	<td colspan="6" style="text-align: center;width:100%">
                		<table id="trailerShowTab" align="center"></table>
                	</td>
               </tr>
               <tr>
               		<td style="width:12%;text-align:right;">
                    	装箱方式<font color="#FF0000">*</font>
                    </td>
                    <td style="padding-left:10px;text-align:left;width:21%;">
                    	<input type="checkbox" id="loadType0" name="loadType0" value="0">
                    	<label for="loadType0">厂装</label>
                    	<input type="checkbox" id="loadType1" name="loadType1" value="1">
                    	<label for="loadType1">港装</label>
                    </td>
               </tr>
               <tr>
               		<td style="width:12%;text-align:right;">
               			<font id="cz" style="display:none">厂装箱型箱量</font><br><br>
               			<font id="gz" style="display:none">港装箱型箱量</font>
                    </td>
                    <td style="padding-left:10px;text-align:left;width:100%;" colspan="5">
                    	<input type="text" id="box_type_factory" name="box_type_factory" style="width:100%;display:none;" onblur="checkBoxType(this)"><br><br>
                    	<input type="text" id="box_type_harbor" name="box_type_harbor" style="width:100%;display:none;" onblur="checkBoxType(this)">
                    </td>
               </tr>
               <tr id="tr3" style="display:none">
                  	<td style="width:12%;text-align:right;">
                  		装箱时间<font color="#FFFFFF">*</font>
                  	</td>
                  	<td style="width:21%;padding-left:10px;text-align:left;">
                  		<input type="text" id="harbour_date" name="harbour_date" class="Wdate" readonly="readonly" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',skin:'whyGreen'})">
                  	</td>
                  	<td style="width:12%;text-align:right;">
                  		预约摆箱时间<font color="#FFFFFF">*</font>
                  	</td>
                  	<td style="width:21%;padding-left:10px;text-align:left;">
                  		<input type="text" id="order_box_date" name="order_box_date" class="Wdate" readonly="readonly" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',skin:'whyGreen'})">
                  	</td>
               </tr>
               <tr id="tr10" style="display:none">
		       		<td style="width:12%;text-align:right;">
		        		货物件数及单位<font color="#FFFFFF">*</font>
		        	</td>
		        	<td style="width:21%;padding-left:10px;text-align:left;">
		        		<input type="text" id="harbour_pkgs" name="harbour_pkgs" style="width:50px">
		        		<input type="text" id="harbour_package" name="harbour_package" style="width:60px">
		        	</td>
		        	<td style="width:12%;text-align:right;">
	               		货物毛重<font color="#FFFFFF">*</font>
	               	</td>
	               	<td style="width:21%;padding-left:10px;text-align:left;">
	               		<input type="text" id="harbour_kg" name="harbour_kg" style="width:120px"> KGS
	               	</td>
	               	<td style="width:12%;text-align:right;">
	               		体积<font color="#FFFFFF">*</font>
	               	</td>
	               	<td style="width:21%;padding-left:10px;text-align:left;">
	               		<input type="text" id="harbour_volume" name="harbour_volume" style="width:120px"> CBM
	               	</td>
               </tr>
               <tr>
               		<td style="width:12%;text-align:right;">
                    	操作备注<font color="#FFFFFF">*</font>
                    </td>
                    <td colspan="5" style="padding-left:10px;text-align:left;">
                    	<textarea id="remarks" name="remarks" style="width:92%;height:100px;"></textarea>
                    </td>
               </tr>
            </table>
        </div>
        <div style="width:100%;text-align:center;margin-top:20px;">
        	<a id="save">保存</a>&nbsp;&nbsp;&nbsp;&nbsp;
        	<input type="hidden" id="userId" name="userId">
        	<input type="hidden" id="aa" name="aa">
        	<input type="hidden" id="startInputTime" name="startInputTime">
        	<input type="hidden" id="tradeCode" name="tradeCode" value="JHJSHANS1803689">
        	<input type="hidden" id="endInputTime" name="endInputTime">
        	<input type="hidden" id="trailerType" name="trailerType">
        	<input type="hidden" id="devanningType" name="devanningType">
	        <input type="hidden" id="trailerAddress" name="trailerAddress">
	        <input type="hidden" id="trailerRemarks" name="trailerRemarks">
	        <input type="hidden" id="trailerDate" name="trailerDate">
	        <input type="hidden" id="trailerPrice" name="trailerPrice">
	        <input type="hidden" id="trailerContact" name="trailerContact">
	        <input type="hidden" id="trailerContactInfo" name="trailerContactInfo">
	        <input type="hidden" id="tradeTrade" name="tradeTrade" value="1">
	        <input type="hidden" id="trade_type" name="trade_type">
        </div>
    </form>
    <div id="boxListDiv">
    	<table id="boxListTab"></table><br>
    	<input type="text" id="boxtype" readonly="readonly">
    	<input type="text" id="boxnum">
    	<a id="boxOk">确认</a>
    	<a id="boxAdd">添加到托单</a>
    	<a id="boxDel">删除</a>
    	<table style="display:none" id="table1">
    		<tr>
    			<td>长</td>
    			<td>
    				<input type="text" id="length" name="tt">m
    			</td>
    			<td>宽</td>
    			<td>
					<input type="text" id="width" name="tt">m
				</td>
    			<td>高</td>
    			<td>
    				<input type="text" id="height" name="tt">m
    			</td>
    			<td>左超</td>
    			<td>
    				<input type="text" id="overLeft" name="tt">m
    			</td>
    			<td>右超</td>
    			<td>
					<input type="text" id="overRight" name="tt">m
				</td>
    		</tr>
    		<tr>
    			<td>前超</td>
    			<td>
    				<input type="text" id="overFore" name="tt">m
    			</td>
    			<td>后超</td>
    			<td>
					<input type="text" id="overBack" name="tt">m
				</td>
    			<td>超高</td>
    			<td>
    				<input type="text" id="overHeight" name="tt">m
    			</td>
    			<td>超限</td>
    			<td>
    				<input type="text" id="overLimit" name="tt">m
    			</td>
    			<td>体积</td>
    			<td>
    				<input type="text" id="volume" name="tt">CBM
    			</td>
    		</tr>
    	</table>
    	<br>
    	<table id="boxList"></table>
    </div>
    <div id="boxNoListDiv" style="text-align:center;">
    	箱号<input type="text" id="boxno">
    	箱型<input type="text" id="box_no_type">
    	<br><br>
    	<a id="boxNoOk">确认</a>
    	<a id="boxNoAdd">添加到托单</a>
    	<a id="boxNoDel">删除</a>
    	<br><br>
    	<table id="boxNoList"></table>
    </div>
    <div id="trailerInfoDiv" style="text-align:center;">
    	<table>
    		<tr>
    			<td style="width:12%;text-align:right;">
              		拖车类型
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
              		<select id="trailerType0">
              			<option value="0">起运港拖车</option>
              			<option value="1">目的港拖车</option>
              		</select>
              	</td>
              	<td style="width:12%;text-align:right;">
              		拖车时间<font color="#FFFFFF">*</font>
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
              		<input type="text" id="trailerDate0" name="trailerDate0" class="Wdate" readonly="readonly" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',skin:'whyGreen'})">
              	</td>
              	<td style="width:12%;text-align:right;">
              		拆装箱类型<font color="#FFFFFF">*</font>
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
					<select id="devanningType0">
              			<option value="0">拆箱</option>
              			<option value="1">装箱</option>
              		</select>              	
              	</td>
    		</tr>
    		<tr>
	        	<td style="width:12%;text-align:right;">
              		地址<font color="#FFFFFF">*</font>
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
              		<textarea style="width:200px;height:80px;" id="trailerAddress0" name="trailerAddress0"></textarea>
              	</td>
              	<td style="width:12%;text-align:right;">
              		拖车备注<font color="#FFFFFF">*</font>
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
              		<textarea style="width:200px;height:80px;" id="trailerRemarks0" name="trailerRemarks0"></textarea>
              	</td>
              	<td style="width:12%;text-align:right;">
              		还箱地<font color="#FFFFFF">*</font>
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
              		<textarea style="width:200px;height:80px;" id="returnBoxAddress0" name="returnBoxAddress0"></textarea>
              	</td>
             </tr>
             <tr>
              	<td style="width:12%;text-align:right;">
              		拖车价格<font color="#FFFFFF">*</font>
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
              		<input type="text" id="trailerPrice0" name="trailerPrice0">
              	</td>
              	<td style="width:12%;text-align:right;">
              		联系人<font color="#FFFFFF">*</font>
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
              		<input type="text" id="trailerContact0" name="trailerContact0">
              	</td>
              	<td style="width:12%;text-align:right;">
              		联系方式<font color="#FFFFFF">*</font>
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
              		<input type="text" id="trailerContactInfo0" name="trailerContactInfo0">
              	</td>
             </tr>
             <tr>
             	<td colspan="6" style="text-align: center;">
             		<a id="trailerAdd">新增</a>
             		<a id="trailerEdit">修改</a>
             		<a id="trailerDel">删除</a>
             	</td>
             </tr>
    	</table>
    	<table id="trailerInfoTab"></table>
    </div>
</body>

<script type="text/javascript">
	var flagc=0;
	var flagd=0;
	var flagcd=0;
	function isDangerous(val){
		$.ajax({
			type:"POST",
			url:"consignMgr/selectDangerous.do",
			dataType:"json",
			data:{keywords:encodeURI(val)},
			success:function(data){
				$.each(data,function(key,value){
					$.messager.confirm('危险品确认',value,function(r){
						if(r){
							$("#tr8").show();
							$("#tr9").show();
							$("#s3").show();
							$("#div3").show();
							$("#s2").hide();
							$("#div2").hide();
							$("#s5").show();
			    			$("#div7").show();
			    			$("#dangerous_name").combogrid("grid").datagrid("reload",{keyword:encodeURI(val)});
			    			$("#dangerous_name").combogrid("setValue",val);
			    			$("#goods_type").combobox("setText","危险品");
			    			$("#goods_type").combobox("setValue","危险品");
						}else{
							$("#tr8").hide();
							$("#tr9").hide();
							$("#s3").hide();
							$("#div3").hide();
							$("#s5").hide();
			    			$("#div7").hide();
			    			$("#goods_type").combobox("setText","普通货物");
			    			$("#goods_type").combobox("setText","普通货物");
			    			$("#goods_type").combobox("setValue","普通货物");
			    			$("#goods_type").val("普通货物");
			    			//删除数据
				    		$('#dangerous_name').combogrid('clear');
							$("#dangerous_type").val('');
							$("#dangerous_level").val('');
							$("#internal_code").val('');
							$("#international_code").val('');
						}
					});
				});
			}
		});
	}
	$(function(){
		if(""!=""){
			$.messager.alert("失败","","error");
		}
		$("input[type=text]").css("border","1px solid #95B8E7");
		$("input[type=text][id!=goods_pkgs][name!=tt][id!=harbour_pkgs][id!=harbour_package][id!=harbour_kg][id!=harbour_volume][id!=goods_weight][id!=goods_measurment]").css("width","150px");
		$("#free_day_remark").css("width","98%");
		$("#box_no").css("width","98%");
		$("#box_type").css("width","98%");
		
		$("#box_type_factory").css("width","70%");
		$("#box_type_harbor").css("width","70%");
		
		$("#length").numberbox({
			width:40,
			precision:2
		});
		$("#length").blur(function(){
			var volume = Number($("#length").val())*Number($("#width").val())*Number($("#height").val());
			$("#volume").numberbox("setValue",volume);
		});
		$("#width").numberbox({
			width:40,
			precision:2
		});
		$("#width").blur(function(){
			var volume = Number($("#length").val())*Number($("#width").val())*Number($("#height").val());
			$("#volume").numberbox("setValue",volume);
		});
		$("#height").numberbox({
			width:40,
			precision:2
		});
		$("#height").blur(function(){
			var volume = Number($("#length").val())*Number($("#width").val())*Number($("#height").val());
			$("#volume").val(volume);
		});
		$("#overLeft").numberbox({
			width:40,
			precision:2
		});
		$("#overRight").numberbox({
			width:40,
			precision:2
		});
		$("#overBack").numberbox({
			width:40,
			precision:2
		});
		$("#overFore").numberbox({
			width:40,
			precision:2
		});
		$("#overLimit").numberbox({
			width:40,
			precision:2
		});
		$("#overHeight").numberbox({
			width:40,
			precision:2
		});
		$("#volume").numberbox({
			width:80,
			precision:2
		});
		
		//2B的贸易类型判断
		$("#trade_mode").change(function(){
			if(this.value=="0"){
				$("#stf").css("color","#FF0000");
			}else if(this.value=="1"){
				$("#stf").css("color","#FFFFFF");
			}
		});
		//查询销售员
		$("#salesManName").combogrid({
			panelWidth:540,
			width:153,
			//height:500,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'id_',    
		    textField: 'name_',
			url:"consignMgr/getSalesPerson.do",
			columns: [[
				{field:'name_',title:'销售员姓名',width:170},
				{field:'department',title:'所属部门',width:170},
				{field:'company_name',title:'所属公司',width:175},
				{field:'id_',title:'销售员ID',hidden:true},
				{field:'company_code',title:'公司ID',hidden:true},
				{field:'departmentid',title:'部门ID',hidden:true}
			]],
			onClickRow:function(){
				salesManName();
			},
			keyHandler: {
				enter:function(){
					var record = pressEnter("salesManName");
					if(record!=null){
						var department = record[0].department;
        				var name = record[0].name_;
        				var id_ = record[0].id_;
        				var departmentid = record[0].departmentid;
        				var companyName = record[0].company_name;
        				var companyCode = record[0].company_code;
        				$("#salesManName").combogrid("setValue",id_);
        				$("#salesManName").combogrid("setText",name);
        				$("#sales_man_dep").val(departmentid);
        				$("#sales_man_dep_show").val(department);
        				$("#sales_man_agent").val(companyCode);
        				$("#sales_man_agent_show").val(companyName);
        				$("#salesManName").val(id_);
					}
				},
				up:function(){
					pressUp("salesManName");
					salesManName();
				},
				down:function(){
					pressDown("salesManName");
					salesManName();
				},
				query: function(q){
					keyword = q;
					//动态搜索  
					$('#salesManName').combogrid("grid").datagrid("reload",{'keyword':keyword});
					$('#salesManName').combogrid("setValue",keyword);
					$("#salesManName").val("");
					$("#sales_man_dep").val("");
    				$("#sales_man_dep").val("");
    				$("#sales_man_agent").val("");
    				$("#sales_man_agent").val("");
					//$('#salesManName').val("grid").datagrid("reload");
				}
			}
		});
		//查询托运人
		$("#agency_man").combogrid({
			panelWidth: 570,
			width:153,
			striped:true,
			pagination:true,
			showHeader:true,
			url:"consignMgr/getCustomer.do",
			queryParams:{tradeFlag:1},
			columns: [[
				{field:'spell_code',title:'检索码',width:50},
				{field:'customer_name',title:'托运人全称',width:205},
				{field:'nm_account_type',title:'付款方式',width:80},
				{field:'customer_type',title:'客户类别',width:50},
				{field:'stop_date',title:'客户协议期',width:100},
				{field:'work_man',title:'托运人联系人',hidden:true},
				{field:'work_phone',title:'托运人联系方式',hidden:true},
				{field:'ac',title:'状态',width:100}
			]],
			onClickRow:function(){
				agencyMan();
			},
			keyHandler: {
				//按键事件测
				enter:function(){
					var record = pressEnter("agency_man");
					if(record!=null){
						var flag = record[0].ac;
        				var customerName = record[0].customer_name;
        				var contact = record[0].work_man;
        				var contactInfo = record[0].work_phone;
        				var customerType = record[0].customer_type;
        				var nmAccountType = record[0].nm_account_type;
        				if(judgeCustomer("agency_man",flag)){
        					$('#agency_man').combogrid("setValue",customerName);
        					$('#agencyContact').combogrid("setValue",customerName);
        					$('#agency_man').val(customerName);
        					$('#agencyContact').val(customerName);
        					$('#pay_way').val(nmAccountType);
        					$('#client_type').val(customerType);
        					$('#contact').val(contact);
        					$('#contact_info').val(contactInfo);
        				}
					}
                },
                //按上方向键移动选择行
                up:function(){
                    pressUp("agency_man");
                    agencyMan();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("agency_man");
                    agencyMan();
                },
				query: function(q) {
					likeSelect(q,"agency_man");
				}
			}
		});
		//查询货主
		$("#agencyContact").combogrid({
			panelWidth: 520,
			width:153,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'id_',    
		    textField: 'customer_name', 
			url:"consignMgr/getCustomer.do",
			queryParams:{tradeFlag:1},
			columns: [[
				{field:'spell_code',title:'检索码',width:50},
				{field:'customer_name',title:'托运人全称',width:205},
				{field:'nm_account_type',title:'付款方式',width:80},
				{field:'customer_type',title:'客户类别',width:50},
				{field:'stop_date',title:'客户协议期',width:100},
				{field:'ac',title:'状态',width:100}
			]],
			onClickRow:function(){
				agencyContact();
			},
			keyHandler: {
				//按键事件测
				enter:function(){
					var record = pressEnter("agencyContact");
					if(record!=null){
						var flag = record[0].ac;
        				var customerName = record[0].customer_name;
        				if(!judgeCustomer("agencyContact",flag)){
        					return;
        				}
        				$('#agencyContact').combogrid("setValue",customerName);
    					$('#agencyContact').val(customerName);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("agencyContact");
                    agencyContact();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("agencyContact");
                    agencyContact();
                },
				query: function(q) {
					//动态搜索  
					$('#agencyContact').combogrid("grid").datagrid("reload",{'keyword':q});
					$('#agencyContact').combogrid("setValue",q);
					$('#agencyContact').val("");
					$('#agencyContact').combogrid("grid").datagrid("reload");
				}
			}
		});
		//查询发货人
		$("#search_shipper").combogrid({
			panelWidth: 570,
			width:100,
			striped:true,
			pagination:true,
			showHeader:true,
			//url:"consignMgr/getConsignee.do",
			columns: [[
				{field:'spell_code',title:'检索码',width:100},
				{field:'consignee_name',title:'详细信息',width:445}
			]],
			onClickRow:function(){
				searchShipper();
			},
			keyHandler: {
				//按键事件测
				enter:function(){
					var record = pressEnter("search_shipper");
					if(record!=null){
						var consigneeName = record[0].consignee_name;
        				var spellCode = record[0].spell_code;
        				$('#search_shipper').combogrid("setValue",spellCode);
        				$("#shipper").val(consigneeName);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("search_shipper");
                	searchShipper();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("search_shipper");
                	searchShipper();
                },
				query: function(q) {
					likeSelect(q,"search_shipper");
				}
			}
		});
		//查询通知人
		$("#search_notice_man").combogrid({
			panelWidth: 570,
			width:100,
			striped:true,
			pagination:true,
			showHeader:true,
			//url:"consignMgr/getConsignee.do",
			columns: [[
				{field:'spell_code',title:'检索码',width:100},
				{field:'consignee_name',title:'详细信息',width:445}
			]],
			onClickRow:function(){
				searchNoticeMan();
			},
			keyHandler: {
				//按键事件测
				enter:function(){
					var record = pressEnter("search_notice_man");
					if(record!=null){
						var consigneeName = record[0].consignee_name;
        				var spellCode = record[0].spell_code;
        				$('#search_notice_man').combogrid("setValue",spellCode);
        				$("#notice_man").val(consigneeName);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("search_notice_man");
                	searchNoticeMan();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("search_notice_man");
                	searchNoticeMan();
                },
				query: function(q) {
					likeSelect(q,"search_notice_man");
				}
			}
		});
		//查询收货人
		$("#search_consignee").combogrid({
			panelWidth: 570,
			width:100,
			striped:true,
			pagination:true,
			showHeader:true,
			//url:"consignMgr/getConsignee.do",
			columns: [[
				{field:'spell_code',title:'检索码',width:100},
				{field:'consignee_name',title:'详细信息',width:445}
			]],
			onClickRow:function(){
				searchConsignee();
			},
			keyHandler: {
				//按键事件测
				enter:function(){
					var record = pressEnter("search_consignee");
					if(record!=null){
						var consigneeName = record[0].consignee_name;
        				var spellCode = record[0].spell_code;
        				$('#search_consignee').combogrid("setValue",spellCode);
        				$("#consignee").val(consigneeName);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("search_consignee");
                	searchConsignee();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("search_consignee");
                	searchConsignee();
                },
				query: function(q) {
					likeSelect(q,"search_consignee");
				}
			}
		});
		//查询装运港
		var index1=0;
		$("#load_harbour").combogrid({
			panelWidth: 570,
			width:153,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'id_',    
		    textField: 'harbour_name', 
			url:"consignMgr/getInlandHarbor.do",
			columns: [[
				{field:'area_name',title:'港口名称',width:142},
				{field:'english_name',title:'港口英文名',width:142},
				{field:'harbour_name',title:'港区',width:142},
				{field:'mileage',title:'里程',width:120}
			]],
			onClickRow:function(){
				loadHarbour();
			},
			keyHandler: {
				//按键事件测
				enter:function(){
					var record = pressEnter("load_harbour");
					if(record!=null){
						var harbourName = record[0].harbour_name;
						var mileage = record[0].mileage;
						$('#load_harbour').combogrid("setValue",harbourName);
						$("#load_harbour").val(harbourName);
						$("#load_harbour_milage").val(mileage);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("load_harbour");
                	loadHarbour();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("load_harbour");
                	loadHarbour();
                },
				query: function(q) {
					likeSelect(q,"load_harbour");
				}
			}
		});
		//查询卸货港
		var index1=0;
		$("#unload_harbour").combogrid({
			panelWidth: 570,
			width:153,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'id_',    
		    textField: 'harbour_name', 
			url:"consignMgr/getInlandHarbor.do",
			columns: [[
				{field:'area_name',title:'港口名称',width:142},
				{field:'english_name',title:'港口英文名',width:142},
				{field:'harbour_name',title:'港区',width:142},
				{field:'mileage',title:'里程',width:120}
			]],
			onClickRow:function(){
				unloadHarbour();
			},
			keyHandler: {
				enter:function(){
					var record = pressEnter("unload_harbour");
					if(record!=null){
						var harbourName = recordp[0].harbour_name;
						var englishName = recordp[0].english_name;
						var mileage = recordp[0].mileage;
						$('#unload_harbour').combogrid("setValue",harbourName);
						$("#unload_harbour").val(harbourName);
 						$("#unload_harbour_milage").val(mileage);
					}
				},
				up:function(){
					pressUp("unload_harbour");
					unloadHarbour();
				},
				down:function(){
					pressDown("unload_harbour");
					unloadHarbour();
				},
				query: function(q) {
					likeSelect(q,"unload_harbour");
				}
			}
		});
		//查询交货地
		$("#stop_harbour").combogrid({
			panelWidth: 570,
			width:153,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'id_',    
		    textField: 'harbour_name',
			url:"consignMgr/getInlandHarbor.do",
			columns: [[
				{field:'area_name',title:'港口名称',width:142},
				{field:'english_name',title:'港口英文名',width:142},
				{field:'harbour_name',title:'港区',width:142},
				{field:'mileage',title:'里程',width:120}
			]],
			onClickRow:function(){
				stopHarbour();
			},
			keyHandler: {
				enter:function(){
					var record = pressEnter("stop_harbour");
					if(record!=null){
						var harbourName = record[0].harbour_name;
						$('#stop_harbour').combogrid("setValue",harbourName);
						$("#stop_harbour").val(harbourName);
					}
				},
				up:function(){
					pressUp("stop_harbour");
					stopHarbour();
				},
				down:function(){
					pressDown("stop_harbour");
					stopHarbour();
				},
				query: function(q) {
					//动态搜索  
					$('#stop_harbour').combogrid("grid").datagrid("reload",{'keyword':q});
					$('#stop_harbour').combogrid("setValue",q);
					$("#stop_harbour").val(q);
					$('#stop_harbour').combogrid("grid").datagrid("reload");
				}
			}
		});
		//可否分批
		$("#partial_flag").combobox({
			width:153,
			editable:false,
			panelHeight:'auto',
			valueField:'value',
		    textField:'text',
		    data: [{value:'1',text:'是'},{value:'0',text:'否'}]
		});
		//显示箱型箱量列表
		$("#boxList").datagrid({
			width:700,
			height:200,
			singleSelect:true,
			striped:true,
			columns:[[    
					{field:'box_type',title:'箱型',width:80},
			        {field:'box_num',title:'箱量',width:80},
			        {field:'length',title:'长',width:50},
			        {field:'width',title:'宽',width:50},
			        {field:'height',title:'高',width:50},
			        {field:'overLeft',title:'左超',width:50},
			        {field:'overRight',title:'右超',width:50},
			        {field:'overFore',title:'前超',width:50},
			        {field:'overBack',title:'后超',width:50},
			        {field:'overLimit',title:'超限',width:50},
			        {field:'overHeight',title:'超高',width:50},
			        {field:'volume',title:'体积',width:75}
			    ]]
		});
		
		//总箱型确认的相关东西
		$("#boxListDiv").dialog({
			title:'箱型确定',
			width:600,    
		    height:500,    
		    modal:true,
		    closed:true
		});
		//显示系统中备案的箱型数据
		$("#boxListTab").datagrid({
			loadMsg:'数据加载中...',
			width:586,
			height:200,
			url:'consignMgr/getBoxType.do',
			singleSelect:true,
			striped:true,
			fit:false,
			columns:[[    
		        {field:'box_code',title:'箱型缩写',width:100},    
		        {field:'box_type_name',title:'箱型名称',width:366},    
		        {field:'box_edi_code',title:'箱型代码',width:100}    
		    ]],
		    onClickRow:function(){
		    	var boxType = $("#boxListTab").datagrid("getSelected").box_code;
		    	$("#boxtype").val(boxType);
		    	if(boxType.indexOf("FR")!=-1||boxType.indexOf("OT")!=-1||boxType.indexOf("FL")!=-1){
		    		$("#table1").show();
		    	}else{
		    		$("#table1").hide();
		    		$("#length").numberbox("clear");
		    		$("#width").numberbox("clear");
		    		$("#height").numberbox("clear");
		    		$("#overLeft").numberbox("clear");
		    		$("#overRight").numberbox("clear");
		    		$("#overFore").numberbox("clear");
		    		$("#overBack").numberbox("clear");
		    		$("#overLimit").numberbox("clear");
		    		$("#overHeight").numberbox("clear");
		    		$("#volume").numberbox("clear");
		    	}
		    }
		});
		//输入箱量
		$("#boxnum").numberbox({
			width:100
		});
		//箱型确定按钮及事件
		$("#boxOk").linkbutton({
			iconCls:'icon-ok'
		});
		$("#boxOk").click(function(){
			var boxType = $("#boxtype").val();
			var boxNum = $("#boxnum").numberbox("getValue");
			var length = $("#length").numberbox("getValue");
			var width = $("#width").numberbox("getValue");
			var height = $("#height").numberbox("getValue");
			var overLeft = $("#overLeft").numberbox("getValue");
			var overRight = $("#overRight").numberbox("getValue");
			var overFore = $("#overFore").numberbox("getValue");
			var overBack = $("#overBack").numberbox("getValue");
			var overLimit = $("#overLimit").numberbox("getValue");
			var overHeight = $("#overHeight").numberbox("getValue");
			var volume = $("#volume").numberbox("getValue");
			if(boxType==''||boxType==null){
				$.messager.alert("提示","箱型不能为空!","warning");
				return;
			}
			if(boxNum==''||boxNum==null){
				$.messager.alert("提示","箱量不能为空!","warning");
				return;
			}
			var rows = $("#boxList").datagrid("getRows");
			for(var i=0;i<rows.length;i++){
				var boxtype=$("#boxList").datagrid('getData').rows[i].box_type;
				var boxnum=$("#boxList").datagrid('getData').rows[i].box_num;
				if(boxtype==boxType){
					$('#boxList').datagrid('updateRow',{index:i,
						row:{box_type:boxType,box_num:boxNum,length:length,overHeight:overHeight,
							width:width,height:height,overLeft:overLeft,overRight:overRight,
							overFore:overFore,overBack:overBack,overLimit:overLimit,volume:volume}});
					$("#boxtype").val("");
					$("#boxnum").numberbox("setValue","");
					$('#boxList').datagrid("clearSelections");
					return;
				}
			}
			$('#boxList').datagrid('appendRow',{box_type:boxType,box_num:boxNum,length:length,
				width:width,height:height,overLeft:overLeft,overRight:overRight,overHeight:overHeight,
				overFore:overFore,overBack:overBack,overLimit:overLimit,volume:volume});
			$("#boxtype").val("");
			$("#boxnum").numberbox("setValue","");
			$('#boxList').datagrid("clearSelections");
			$("#length").numberbox("clear");
    		$("#width").numberbox("clear");
    		$("#height").numberbox("clear");
    		$("#overLeft").numberbox("clear");
    		$("#overRight").numberbox("clear");
    		$("#overFore").numberbox("clear");
    		$("#overBack").numberbox("clear");
    		$("#overLimit").numberbox("clear");
    		$("#overHeight").numberbox("clear");
    		$("#volume").numberbox("clear");
		});
		//添加箱型箱量到托单的按钮及事件
		$("#boxAdd").linkbutton({
			iconCls:'icon-add'
		});
		$("#boxAdd").click(function(){
			var rows = $.extend([],$("#boxList").datagrid("getRows"));
			var boxType = "";
			var bigBox = 0;
			var smallBox = 0;
			var bigBoxH = 0;
			var bigbigBox = 0;
			for(var i=0;i<rows.length;i++){
				var boxtype=rows[i].box_type;
				var boxnum=rows[i].box_num;
				//删除行	
				$("#boxList").datagrid("deleteRow",0);
				if(boxtype.indexOf("20")!=-1){
					smallBox += Number(boxnum);
				}else if(boxtype.indexOf("45")!=-1){
					bigbigBox += Number(boxnum);
				}else if(boxtype.indexOf("40")!=-1&&boxtype.indexOf("HC")!=-1){
					bigBoxH += Number(boxnum);
				}else if(boxtype.indexOf("40")!=-1&&boxtype.indexOf("HC")==-1){
					bigBox += Number(boxnum);
				}
				boxType += boxnum+"X"+boxtype+"&&";
			}
			if(boxType.length>0){
				boxType = boxType.substring(0,boxType.length-2);
			}
			$("#"+id).val(boxType);
			$("#boxListDiv").dialog("close");
			if("box_type"==id){
				$("#big_box").val(bigBox);
				$("#bigbig_box").val(bigbigBox);
				$("#big_boxh").val(bigBoxH);
				$("#small_box").val(smallBox);
			}
			//判断装箱方式处是否勾选,并自动带入箱型箱量
			if($("#loadType0").is(':checked')){//只能放厂装
				$("#loadBox0").val(boxType);
			}else if($("#loadType1").is(':checked')&&!$("#loadType0").is(':checked')){
				$("#loadBox1").val(boxType);
			}
		});
		//提单类型
		$("#bol_type").combobox({
			panelHeight:'auto',
			width:153,
			editable:false,
			valueField:'bol_type_id',
			textField:'bol_type',
			url:'consignMgr/getBolType.do',
			onLoadSuccess:function(){
				$("#bol_type").combobox("setValue","");
			}
		});
		//货源
		$("#supply_of_goods").combobox({
			panelHeight:'auto',
			width:153,
			editable:false,
			url:'consignMgr/getGoodsSourceCombo.do',
			valueField:'goods_type_name_code',
			textField:'goods_type_name',
			onLoadSuccess:function(){
				$("#supply_of_goods").combobox("setValue","");
			}
		});
		var id="";
		//显示箱型确定界面 -------总箱型
		$('#box_type').focus(function(){
			var hasBoxType=$("#box_type").val();
			var hasBoxTypes=hasBoxType.split("&&"); 
			//首先清空表格中的所有数据
			var rows=$("#boxList").datagrid("getRows");
			for(var i=0;i<rows.length;i++){
				$("#boxList").datagrid("deleteRow",i);
			}
			//添加表格数据
			for(var i=0;i<hasBoxTypes.length;i++){
				if(hasBoxTypes[i]!=""){
					var type = hasBoxTypes[i].split("X")[1];
					var num = hasBoxTypes[i].split("X")[0];
					$('#boxList').datagrid('appendRow',{box_type:type,box_num:num});
				}
			}
			id="box_type";
			$("#boxListDiv").dialog("open");
			autoLocation("boxListDiv","400");
		});
		//删除按钮
		$("#boxDel").linkbutton({
			iconCls:'icon-cancel'
		});
		$("#boxDel").bind("click",function(){
			var row = $("#boxList").datagrid("getSelected");
			var rowIndex = $("#boxList").datagrid("getRowIndex",row);
			$("#boxList").datagrid("deleteRow",rowIndex);
		});
		//显示增加箱号div
		$("#boxNoListDiv").dialog({
			title:"请输入箱号",
			width:400,
			height:300,
			modal:true,
			closed:true
		});
		//箱号显示表格
		$("#boxNoList").datagrid({
			width:360,
			striped:true,
			ctrlSelect:true,
			columns:[[    
			        {field:'box_no',title:'箱号',width:260},
			        {field:'box_no_type',title:'箱型',width:100}
			    ]]
		});
		//可否转船
		$("#change_ship_flag").combobox({
			width:153,
			editable:false,
			panelHeight:'auto',
			valueField:'value',
		    textField:'text',
		    data: [{value:'1',text:'是'},{value:'0',text:'否'}]
		});
		//箱主
		$("#box_master").combogrid({
			panelWidth: 570,
			width:153,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'id_',    
		    textField: 'cq_code',
			url:"consignMgr/getBoxMaster.do",
			columns: [[
						{field:'spell_code',title:'检索码',width:80},
						{field:'cq_code',title:'箱主代码',width:80},
						{field:'full_name',title:'箱主全称',width:160},
						{field:'remrk',title:'备注',width:200}
					]],
			onClickRow:function(){
				boxMaster();
			},
			keyHandler: {
				enter:function(){
					var record=pressEnter("box_master");
					if(record!=null){
						var cqCode = record[0].cq_code;
						var remrk = record[0].remrk;
						var id = record[0].id_;
						$('#box_master').combogrid("setValue",id+"@"+cqCode);
						$("#box_master").val(cqCode);
					}
				},
				up:function(){
					pressUp("box_master");
					boxMaster();
				},
				down:function(){
					pressDown("box_master");
					boxMaster();
				},
				query: function(q) {
					likeSelect(q, "box_master");
				}
			}
		});
		//校验并新增箱号
		var hasBoxType={};
		$("#boxNoOk").linkbutton({
			iconCls:'icon-ok'
		});
		$("#boxNoOk").bind("click",function(){
			var boxNo = $("#boxno").val();
			var boxNoType = $("#box_no_type").combobox("getValue");
			var num = $("#box_no_type").combobox("getText");
			num = num.substring(0,num.indexOf("X"));
			if(boxNo==''||boxNo==null){
				$.messager.alert("提示","箱号不能为空!","warning");
				return;
			}
			if(!checkBox(boxNo)){
				$.messager.alert("错误","箱号错误!","error");
				return;
			}
			if(boxNoType==""||boxNoType==null){
				$.messager.alert("错误","请选择箱型!","watning");
				return;
			}
			if(hasBoxType[boxNoType]>=num||num==0){
				$.messager.alert("错误",boxNoType+"的箱型箱号已添加到最大数量!","error");
				return;
			}
			var rows = $("#boxNoList").datagrid("getRows");
			for(var i=0;i<rows.length;i++){
				var boxno=$("#boxNoList").datagrid('getData').rows[i].box_no;
				if(boxno==boxNo){
					$.messager.alert("错误","不能添加相同的箱号!","error");
					return;
				}
			}
			$('#boxNoList').datagrid('appendRow',{box_no:boxNo,box_no_type:boxNoType});
			if(hasBoxType[boxNoType]==undefined){
				hasBoxType[boxNoType]=1;
			}else{
				hasBoxType[boxNoType]=hasBoxType[boxNoType]+1;
			}
			$("#boxno").val("");
		});
		var data=[];
		//指定箱型列表
		$("#box_no_type").combobox({
			panelHeight:'auto',
			width:150,
			valueField:'type',
		    textField:'num',
		    data:data
		});
		//添加箱号到托单
		$("#boxNoAdd").linkbutton({
			iconCls:'icon-add'
		});
		$("#boxNoAdd").bind("click",function(){
			var boxNo="";
			var htype="";
			var rows = $("#boxNoList").datagrid("getRows");
			for(var i=0;i<rows.length;i++){
				var boxno=$("#boxNoList").datagrid('getData').rows[i].box_no;
				var box_no_type=$("#boxNoList").datagrid('getData').rows[i].box_no_type;
				boxNo += boxno+",";
				htype += box_no_type+",";
			}
			if(boxNo.length>0){
				boxNo = boxNo.substring(0,boxNo.length-1);
				htype = htype.substring(0,htype.length-1);
			}
			$("#box_no").val(boxNo);
			$("#hBoxType").val(htype);
			$("#boxno").val("");
			$("#boxNoListDiv").dialog("close");
		});
		//删除已添加箱号
		$("#boxNoDel").linkbutton({
			iconCls:'icon-cancel'
		});
		$("#boxNoDel").bind("click",function(){
			var rows = $("#boxNoList").datagrid("getSelections");
			for(var i=0;i<rows.length;i++){
				var rowIndex = $("#boxNoList").datagrid("getRowIndex",rows[i]);
				$("#boxNoList").datagrid("deleteRow",rowIndex);
			}
		});
		//是否指定用箱
		$("#specified_box").combobox({
			width:153,
			editable:false,
			panelHeight:'auto',
			valueField:'value',
			textField:'text',
			data:[{value:'0',text:'否'},{value:'1',text:'是'},{value:'2',text:'自备箱'}],
			onChange:function(q){
				if("1"==q||"2"==q){
					$("#box_no").show();
					$("#s6").show();
				}else{
					$("#box_no").val("");
					$("#box_no").hide();
					$("#s6").hide();
				}
				return;
			}
		});
		//代办保险
		var flag = 0;
		$("#insurance").combobox({
			width:153,
			panelHeight:'auto',
			editable:false,
			valueField:'value',
			textField:'text',
			data:[{value:'0',text:'否'},{value:'1',text:'是'}],
		    onChange:function(q){
		    	if("1"==q){
		    		$("#s7").show();
		    		$("#s8").show();
		    		$("#tr11").show();
		    		$("#bxmc").show();
		    		$("#bxje").show();
		    		if(flag==0){
		    			flag=1;
		    			$("#bxje").numberbox({
		    				precision:2
		    			});
		    			$("#bxbl").numberbox({
		    				precision:4
		    			});
		    		}
		    	}else{
		    		$("#s7").hide();
		    		$("#s8").hide();
		    		$("#tr11").hide();
		    		$("#bxmc").hide();
		    		$("#bxje").hide();
		    		$("#bxmc").val("");
		    		$("#bxje").val("");
		    		$("#bxbl").val("");
		    		$("#bz").val("");
		    	}
		    }
		});
		//是否安排拖车
 		$("#is_trailer").change(function(){
			if("2"==this.value){
	    		$("#trailerInfo").show();
	    	}else{
	    		$("#trailerInfo").hide();
	    		$("#trailerTr").hide();
	    		var rows = $("#trailerInfoTab").datagrid("getRows");
	    		for(var i=0;i<rows.length;i++){
					var rowIndex = $("#trailerInfoTab").datagrid("getRowIndex",rows[i]);
					$("#trailerInfoTab").datagrid("deleteRow",rowIndex);
				}
	    	}
		});
		//修改拖车信息
		$("#trailerInfo").linkbutton({
			inconCls:'icon-edit'
		});
		$("#trailerInfo").click(function(){
			$("#trailerInfoDiv").dialog("open");
			autoLocation("trailerInfoDiv", "400")
		});
		//新增拖车信息
		$("#trailerAdd").linkbutton({
			iconCls:'icon-add'
		});
		$("#trailerAdd").click(function(){
			var trailerType0=$("#trailerType0").val();
			var trailerAddress0=$("#trailerAddress0").val();
			var trailerRemarks0=$("#trailerRemarks0").val();
			var returnBoxAddress0=$("#returnBoxAddress0").val();
			var trailerDate0=$("#trailerDate0").val();
			var trailerPrice0=$("#trailerPrice0").val();
			var trailerContact0=$("#trailerContact0").val();
			var trailerContactInfo0=$("#trailerContactInfo0").val();
			var devanningType0=$("#devanningType0").val();
			if("1"==trailerType0){
				trailerType0="目的港拖车";
			}else{
				trailerType0="起运港拖车";
			}
			if("1"==devanningType0){
				devanningType0="装箱";
			}else{
				devanningType0="拆箱";
			}
			$("#trailerInfoTab").datagrid('appendRow',{trailer_type:trailerType0,trailer_address:trailerAddress0,
				trailer_remarks:trailerRemarks0,trailer_date:trailerDate0,trailer_price:trailerPrice0,devanning_type:devanningType0,
				trailer_contact:trailerContact0,trailer_contact_info:trailerContactInfo0,return_box_address:returnBoxAddress0});
			$("#trailerType0").val("");
			$("#devanningType0").val("");
			$("#returnBoxAddress0").val("");
			$("#trailerAddress0").val("");
			$("#trailerRemarks0").val("");
			$("#trailerDate0").val("");
			$("#trailerPrice0").val("");
			$("#trailerContact0").val("");
			$("#trailerContactInfo0").val("");
		});
		//修改拖车信息
		$("#trailerEdit").linkbutton({
			iconCls:'icon-edit'
		});
		$("#trailerEdit").click(function(){
			var trailerType0 = $("#trailerType0").val();
			if("1"==trailerType0){
				trailerType0='目的港拖车';
			}else{
				trailerType0='起运港拖车';
			}
			var devanningType0=$("#devanningType0").val();
			if("1"==devanningType0){
				devanningType0="装箱";
			}else{
				devanningType0="拆箱";
			}
			var trailerAddress0=$("#trailerAddress0").val();
			var trailerRemarks0=$("#trailerRemarks0").val();
			var returnBoxAddress0=$("#returnBoxAddress0").val();
			var trailerDate0=$("#trailerDate0").val();
			var trailerPrice0=$("#trailerPrice0").val();
			var trailerContact0=$("#trailerContact0").val();
			var trailerContactInfo0=$("#trailerContactInfo0").val();
			$('#trailerInfoTab').datagrid('updateRow',{
				index:aaIndex,
				row: {
					devanning_type: devanningType0,
					trailer_type: trailerType0,
					trailer_address: trailerAddress0,
					trailer_remarks: trailerRemarks0,
					return_box_address: returnBoxAddress0,
					trailer_date: trailerDate0,
					trailer_price: trailerPrice0,
					trailer_contact: trailerContact0,
					trailer_contact_info: trailerContactInfo0
				}
			});
			$("#trailerType0").val("");
			$("#devanningType0").val("");
			$("#trailerAddress0").val("");
			$("#trailerRemarks0").val("");
			$("#returnBoxAddress0").val("");
			$("#trailerDate0").val("");
			$("#trailerPrice0").val("");
			$("#trailerContact0").val("");
			$("#trailerContactInfo0").val("");
		});
		//删除拖车信息
		$("#trailerDel").linkbutton({
			iconCls:'icon-cancel'
		});
		$("#trailerDel").click(function(){
			var rows=$("#trailerInfoTab").datagrid("getSelections");
			if(rows.length<=0){
				$.messager.alert("提示","请选择删除的记录","info");
				return;
			}
			for(var i=0;i<rows.length;i++){
				var rowIndex = $("#trailerInfoTab").datagrid("getRowIndex",rows[i]);
				$("#trailerInfoTab").datagrid("deleteRow",rowIndex);
			}
		});
		//拖车信息修改DIV
		$("#trailerShowTab").datagrid({
			width:930,
			singleSelect:true,
			striped:true,
			url:'consignMgr/getTrailerInfo.do',
			columns:[[    
		          {field:'trailer_type',title:'拖车类型',width:50},
		          {field:'devanning_type',title:'拆装箱类型',width:80},
		          {field:'trailer_address',title:'地址',width:150},
		          {field:'trailer_remarks',title:'拖车备注',width:150},
		          {field:'return_box_address',title:'还箱地',width:150},
		          {field:'trailer_date',title:'拖车日期',width:80},
		          {field:'trailer_price',title:'拖车价格',width:80},
		          {field:'trailer_contact',title:'联系人',width:100},
		          {field:'trailer_contact_info',title:'联系方式',width:100}
		    ]]
		});
		tooltip("trailerShowTab","200px");
		var ttindex=0;
		$("#trailerInfoDiv").dialog({
			title:'拖车信息修改',
			width:900,
			height:400,
			modal:true,
			closed:true,
			onClose:function(){
				//托单界面显示拖车信息
				var rows=null
				try{
					rows = $("#trailerShowTab").datagrid("getRows");
					for(var i=0;i<rows.length;){
						$('#trailerShowTab').datagrid('deleteRow',0);
					}
					$("#trailerShowTab").datagrid("destroy",true)
				}catch(e){
					
				}
				try {
					rows = $("#trailerInfoTab").datagrid("getRows");
					if(rows.length>0){
						$("#trailerTr").show();
					}else{
						$("#trailerTr").hide();
					}
					for(var i=0,j=rows.length;i<j;i++){
						$('#trailerShowTab').datagrid('appendRow',rows[i]);
					}
					if(rows.length>0){
						$("#trailerTr").show();
					}
				} catch (e) {
					
				}
			}
		});
		var aaIndex="";
		//拖车信息列表
		$("#trailerInfoTab").datagrid({
			width:930,
			height:190,
			columns:[[
		          {field:'trailer_type',title:'拖车类型',width:50},
		          {field:'devanning_type',title:'拆装箱类型',width:80},
		          {field:'trailer_address',title:'地址',width:150},
		          {field:'trailer_remarks',title:'拖车备注',width:150},
		          {field:'return_box_address',title:'还箱地',width:150},
		          {field:'trailer_date',title:'拖车日期',width:80},
		          {field:'trailer_price',title:'拖车价格',width:80},
		          {field:'trailer_contact',title:'联系人',width:100},
		          {field:'trailer_contact_info',title:'联系方式',width:100}
		      ]],
			onClickRow:function(index,row){
				aaIndex=index;
				var trailerType0=row.trailer_type;
				var devanningType0=row.devanning_type;
				var trailerAddress0=row.trailer_address;
				var trailerRemarks0=row.trailer_remarks;
				var returnBoxAddress0=row.return_box_address;
				var trailerDate0=row.trailer_date;
				var trailerPrice0=row.trailer_price;
				var trailerContact0=row.trailer_contact;
				var trailerContactInfo0=row.trailer_contact_info;
				if("目的港拖车"==trailerType0){
					trailerType0='1';
				}else{
					trailerType0='0';
				}
				if("装箱"==devanningType0){
					devanningType0="1";
				}else{
					devanningType0="0";
				}
				$("#trailerType0").val(trailerType0);
				$("#devanningType0").val(devanningType0);
				$("#trailerAddress0").val(trailerAddress0);
				$("#trailerRemarks0").val(trailerRemarks0);
				$("#returnBoxAddress0").val(returnBoxAddress0);
				$("#trailerDate0").val(trailerDate0);
				$("#trailerPrice0").val(trailerPrice0);
				$("#trailerContact0").val(trailerContact0);
				$("#trailerContactInfo0").val(trailerContactInfo0);
			}
		});
		
		//港装的坑比包装选择
		$("#harbour_package").combogrid({
  			panelWidth: 452,
			width:90,
			striped:true,
			pagination:true,
			showHeader:true,
			url:"consignMgr/getPackaging.do",
			columns: [[
				{field:'spell_code',title:'快捷代码',width:114},
				{field:'packaging',title:'包装方式',width:114},
				{field:'remark',title:'备注',width:114}
			]],
			onClickRow:function(){
				harbourPackage();
			},
			keyHandler: {
				//按键事件测
				enter:function(){
					var record = pressEnter("harbour_package");
					if(record!=null){
						var packaging = record[0].packaging;
        				$('#harbour_package').val(packaging);
        				$('#harbour_package').combogrid("setValue",packaging);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("harbour_package");
					harbourPackage();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("harbour_package");
					harbourPackage();
                },
				query: function(q) {
					likeSelect(q,"harbour_package");
				}
			}
   		});
		//2B的装箱方式选择
		$("#loadType0").click(function(){
			if($(this).is(':checked')){
				$("#box_type_factory").show();
				$("#cz").show();
				$("#box_type_factory").val($("#box_type").val());
				calculateBox(document.getElementById("box_type_harbor"));
			}else{
				$("#box_type_factory").hide();
				$("#cz").hide();
				$("#box_type_factory").val("");
				if($("#loadType1").is(':checked')){
					$("#box_type_harbor").val($("#box_type").val());
				}
			}
		});
		$("#loadType1").click(function(){
			if($(this).is(':checked')){
				$("#box_type_harbor").show();
				$("#tr3").show();
				$("#tr10").show();
				$("#gz").show();
				$("#lbrf").show();
				$("#load_box_remark").show();
				$("#box_type_harbor").val($("#box_type").val());
				$("#harbour_pkgs").val($("#goods_pkgs").val());
				$("#harbour_kg").val($("#goods_weight").val());
				$("#harbour_volume").val($("#goods_measurment").val());
				$("#harbour_package").val($("#goods_package").val());
				$("#harbour_package").combogrid("setValue",$("#goods_package").val());
				calculateBox(document.getElementById("box_type_factory"));
			}else{
				$("#box_type_harbor").hide();
				$("#tr3").hide();
				$("#tr10").hide();
				$("#gz").hide();
				$("#lbrf").hide();
				$("#load_box_remark").hide();
				$("#box_type_harbor").val("");
				$("#harbour_pkgs").val("");
				$("#harbour_kg").val("");
				$("#harbour_volume").val("");
 				$("#harbour_package").val("");
				$("#harbour_package").combogrid("setValue","");
				if($("#loadType0").is(':checked')){
					$("#box_type_factory").val($("#box_type").val());
				}
			}
		});
		//危险品
		$("#dangerous_name").combogrid({
			panelWidth: 570,
			width:153,
			striped:true,
			pagination:true,
			showHeader:true,
			url:"consignMgr/getDangerous.do",
			columns: [[
				{field:'dangerous_name',title:'危险品名',width:114},
				{field:'dangerous_type',title:'危险品种类',width:114},
				{field:'main_level',title:'危险品等级',width:114},
				{field:'internal_code',title:'国内代码',width:114},
				{field:'international_code',title:'国际代码',width:114}
			]],
			onClickRow:function(){
				dangerousName();
			},
			onLoadSuccess:function(){
				var rows = $("#dangerous_name").combogrid("grid").datagrid("getRows");
				if(rows.length<=1){
					$("#dangerous_type").val(rows[0].dangerous_type);
					$("#dangerous_level").val(rows[0].main_level);
					$("#internal_code").val(rows[0].internal_code);
					$("#international_code").val(rows[0].international_code);
				}
			},
			keyHandler: {
				//按键事件测
				enter:function(){
					var record = pressEnter("dangerous_name");
					if(record!=null){
						var dangerousName = record[0].dangerous_name;
 					var mainLevel = record[0].main_level;
 					var dangerousType = record[0].dangerous_type;
 					var internalCode = record[0].internal_code;
 					var internationalCode = record[0].international_code;
 					$('#dangerous_name').val(dangerousName);
 					$("#dangerous_type").val(dangerousType);
 					$("#dangerous_level").val(mainLevel);
 					$("#internal_code").val(internalCode);
 					$("#international_code").val(internationalCode);
 					$('#dangerous_name').combogrid("setValue",dangerousName);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("dangerous_name");
                	dangerousName();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("dangerous_name");
                	dangerousName();
                },
				query: function(q) {
					likeSelect(q,"dangerous_name");
				}
			}
   		});
		//货物种类
		$("#goods_type").combobox({
			width:153,
			panelHeight:'auto',
			editable:false,
			valueField:'goods_type_name',
			textField:'goods_type_name',
			url:'consignMgr/getGoodsTypeName.do',
		    onChange:function(){
		    	var value = $('#goods_type').combobox("getValue");
				if(("普通货物"==value||"活动物"==value)){
					$("#tr8").hide();
					$("#tr9").hide();
					$("#s2").hide();
					$("#s3").hide();
					$("#div2").hide();
					$("#div3").hide();
					//删除数据
					if(flagd!=0&&flagcd!=0){
		    			$('#dangerous_name').combogrid('clear');
					}
					if(flagc!=0&&flagcd!=0){
						$("#cold_rem").numberbox('clear');
					}
					$("#dangerous_type").val('');
					$("#dangerous_level").val('');
					$("#internal_code").val('');
					$("#international_code").val('');
				}else if("冷藏品"==value){
					$("#s2").show();
					$("#div2").show();
					$("#tr8").hide();
	    			$("#tr9").show();
	    			$("#s3").hide();
	    			$("#div3").hide();
	    			$("#s5").hide();
	    			$("#div7").hide();
					if(flagc==0&&flagcd==0){
						$("#cold_rem").numberbox({
		    				width:153,
		    				precision:2
		    			});
						flagc==1
					}else{
		    			//删除数据
		    			$('#dangerous_name').combogrid('clear');
						$("#dangerous_type").val('');
						$("#dangerous_level").val('');
						$("#internal_code").val('');
						$("#international_code").val('');
					}
				}else if("危险品"==value){
					$("#tr8").show();
					$("#tr9").show();
					$("#s3").show();
					$("#div3").show();
					$("#s2").hide();
					$("#div2").hide();
					$("#s5").show();
	    			$("#div7").show();
					if(flagd==0&&flagcd==0){
						
					}else{
		    			$("#s2").hide();
		    			$("#div2").hide();
		    			//删除数据
						$("#cold_rem").numberbox('clear');
					}
				}else if("危险冷藏品"==value){
					$("#tr8").show();
					$("#tr9").show();
					$("#s2").show();
					$("#s3").show();
					$("#div2").show();
					$("#div3").show();
					$("#s5").show();
	    			$("#div7").show();
					if(flagcd==0){
						if(flagc==0){
							$("#cold_rem").numberbox({
			    				width:153,
			    				precision:2
			    			});
						}
		    			flagcd=1;
					}
				}
		    }
		});
		//查询包装
		$("#goods_package").combogrid({
  			panelWidth: 452,
			width:95,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'id_',    
		    textField: 'packaging',
			url:"consignMgr/getPackaging.do",
			columns: [[
				{field:'spell_code',title:'快捷代码',width:114},
				{field:'packaging',title:'包装方式',width:114},
				{field:'remark',title:'备注',width:114}
			]],
			onClickRow:function(){
				goodsPackage();
			},
			keyHandler: {
				enter:function(){
					var record = pressEnter("goods_package");
					if(record!=null){
						var packaging = record[0].packaging;
						$('#goods_package').val(packaging);
						$('#goods_package').combogrid("setValue",packaging);
					}
				},
				up:function(){
					pressUp("goods_package");
					goodsPackage();
				},
				down:function(){
					pressDown("goods_package");
					goodsPackage();
				},
				query: function(q) {
					likeSelect(q, "goods_package");
				}
			}
   		});
		
		//价格来源
		$("#price_source").combobox({
			width:153,
			panelHeight:'auto',
			editable:false,
			valueField:'value',
			textField:'text',
			data:[{value:'1',text:'自拿价'},{value:'0',text:'销售拿价'},{value:'2',text:'市场报价'}],
		    onChange:function(q){
		    	if("2"==q){
		    		$("#enquiry_no").attr("disabled",false);
		    	}else{
		    		$("#enquiry_no").val("");
		    		$("#enquiry_no").attr("disabled",true);
		    	}
		    }
		});
		//付费方式
		$("#carriage_type").combobox({
			width:153,
			panelHeight:'auto',
			editable:false,
			valueField:'value',
			textField:'text',
			data:[{value:'月结',text:'月结'},{value:'预付',text:'预付'},{value:'到付',text:'到付'},{value:'第三地付费',text:'第三地付费'}],
			onSelect:function(a){
				$("#carriage_type").combobox("setText",a.value);
			},
			onChange:function(q){
		    	if(q=="第三地付费"){
		    		$("#div4").show();
		    		$("#s4").show();
		    	}else{
		    		$("#div4").hide();
		    		$("#s4").hide();
		    		$("#third_place").val("");
		    	}
		    }
		});
		//查询运输条款
		$("#transport_item").combogrid({
			panelWidth: 570,
			width:153,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'id_',    
		    textField: 'transport_item', 
			url:"consignMgr/getTransportItem.do",
			columns: [[
						{field:'spell_code',title:'条款简码',width:142},
						{field:'start_item',title:'起始条款',width:142},
						{field:'end_item',title:'终止条款',width:142},
						{field:'transport_item',title:'运输条款',width:120}
					]],
			onClickRow:function(){
				transportItem();
			},
			keyHandler: {
				enter:function(){
					var record=pressEnter("transport_item");
					if(record!=null){
						var transportItem = record[0].transport_item;
						var id = record[0].id_;
						$('#transport_item').combogrid("setValue",id+"@"+transportItem);
						$("#transport_item").combogrid("setText",transportItem);
						$("#transport_item").val(transportItem);
					}
				},
				up:function(){
					pressUp("transport_item");
					transportItem();
				},
				down:function(){
					pressDown("transport_item");
					transportItem();
				},
				query: function(q) {
					likeSelect(q, "transport_item");
				}
			}
		});
		//获取登录用户ID
		getUserId();
		//获取托单录入开始时间
		getNowTime("startInputTime");
		//提交保存数据
		$("#save").linkbutton({
			iconCls:'icon-save'
		});
		var subIndex=0;
		$("#save").bind("click",function(){
			//获取托单录入结束时间
			getNowTime("endInputTime");
			if(checkSave()){
				if(subIndex!=0){
					$.messager.alert("警告","你家的网络已经走丢了,你就不能耐心地等等吗?","warning");
					return;
				}
				//组装TMD拖车信息
				var rows = $("#trailerInfoTab").datagrid("getRows");
				var trailerType="";
 				var trailerAddress="";
				var trailerRemarks="";
				var returnBoxAddress="";
				var trailerDate="";
				var trailerPrice="";
				var trailerContact="";
				var trailerContactInfo="";
				var devanningType="";
				for(var i=0;i<rows.length;i++){
					var row=rows[i];
					if("目的港拖车"==row.trailer_type){
						trailerType+="1!@";
					}else{
						trailerType+="0!@";
					}
					if("装箱"==row.devanning_type){
						devanningType+="1!@";
					}else{
						devanningType+="0!@";
					}
					trailerAddress+=row.trailer_address+"!@";
					trailerRemarks+=row.trailer_remarks+"!@";
					trailerDate+=row.trailer_date+"!@";
					trailerPrice+=row.trailer_price+"!@";
					trailerContact+=row.trailer_contact+"!@";
					trailerContactInfo+=row.trailer_contact_info+"!@";
					returnBoxAddress+=row.return_box_address+"!@";
				}
				$("#trailerType").val(trailerType);
				$("#devanningType").val(devanningType);
				$("#trailerAddress").val(trailerAddress);
				$("#trailerRemarks").val(trailerRemarks);
				$("#returnBoxAddress").val(returnBoxAddress);
				$("#trailerDate").val(trailerDate);
				$("#trailerPrice").val(trailerPrice);
				$("#trailerContact").val(trailerContact);
				$("#trailerContactInfo").val(trailerContactInfo);
				subIndex=1;
				var aa = "";
				for(var i = 0;i<rows.length;i++){
					var boxType = rows[i].box_type;
					var length = rows[i].length;
					var width = rows[i].width;
					var height = rows[i].height;
					var overLeft = rows[i].over_left;
					var overRight = rows[i].over_right;
					var overFore = rows[i].over_fore;
					var overBack = rows[i].over_back;
					var overLimt = rows[i].over_limt;
					var overHeight = rows[i].overHeight;
					var volume = rows[i].volume;
					aa += boxType+"!"+length+","+width+","+height+","+overLeft+","+overRight+","+overFore+","+overBack+","+overLimt+","+overHeight+","+volume+";"
				}
				$("#aa").val(aa);
				
				$.ajax({
	                type: "POST",
 	                url:"consignMgr/consignEdit.do",
	                data:encodeURI($('#form1').serialize()),
	                async: false,
	                error: function(request) {
	                	subIndex=0;
	                    alert("Connection error");
	                },
	                success: function(msg) {
	                	subIndex=0;
	                   $.messager.alert("操作结果",msg,"info");
	                }
	            });
			}
		});
		//返回
		$("#goBack").linkbutton({
			iconCls:'icon-back'
		});
		$("#goBack").click(function(){
			if('consignOrderList.jsp'==0){
				window.close();
			}else{
				location.href="consignOrderList.jsp?tradeCode=JHJSHANS1803689";
			}
		});
		var type= "1";
		if("2"==type){
			$("#bigDiv3 input").attr("disabled",true);
			$("#bigDiv3 textarea").attr("disabled",true);
			$("#price_source").combobox("disable");
			$("#carriage_type").combobox("disable");
			$("#transport_item").combogrid("disable");
			$("#tradeFlag").val("2");
		}
		getConsignInfo();
	});
	
	//查询托单信息
	function getConsignInfo(){
		var salesManName = "";
		var salesManId = "";
		var salesManName2 = "";
		var salesManId2 = "";
		
		var boxMaster_id = "";
		var transportItem_id = "";
		var agencyManId = "";
		var bolType_id = "";
		var gateUnitId = "";
		var portOfLoadingId = "";
		var placeOfDeliveryId = "";
		
		var loadHarbourId = "";
		var unloadHarbourId = "";
		var stop_harbourId = "";
		var bolType_id = "";
		var goods_packageId = "";
		var transportItemId = "";
		
		$.ajax({
			type:"POST",
			url:"consignMgr/getTradeInfo.do",
			data:{tradeCode:document.getElementById("billCode").innerText},
			dataType:"json",
			error:function(){
				alert("123");
			},
			success:function(data){
				$.each(data[0],function(key,value){
					var index=0;
					//设置文本框的值
					try {
						if(key=="is_buy_class"){
							$("#isBuyClass").val(value);
						}
						if(key=="boxTypeFactory"){
							$("#loadBox0").val(value);
						}else if(key=="agencySelfNo"){
							$("#agency_self_no").val(value);//自编号
						}else if(key=="contactInfo"){
							$("#contact_info").val(value);//托运人联系方式
						}else if(key=="clientType"){
							$("#client_type").val(value);//客户类别
						}else if(key=="payWay"){							
							$("#pay_way").val(value);//付款方式
						}else if(key=="noticeMan"){							
							$("#notice_man").val(value);//通知人
						}else if(key=="goodsEnglishName"){
							$("#goods_english_name").val(value);//货物描述
						}else if(key=="goodsChineseName"){
							$("#goods_chinese_name").val(value);//中文品名
						}else if(key=="bolType_id"){
							bolType_id = value;
							$("#bolType_Id").val(value);
						}else if(key=="bolType"){
							$("#bol_type").combobox("setValue",value);//提单类型
						}else if(key=="goodsMeasurment"){
							$("#goods_measurment").val(value);//体积
						}else if(key=="partialFlag"){
							$("#partial_flag").combobox("setValue",value);//可否分批
						}else if(key=="goodsPkgs"){
							$("#goods_pkgs").val(value);//货物件数及单位
						}else if(key=="loadDate"){
							$("#load_date").val(value);//预计装船时间
						}else if(key=="changeShipFlag"){
							$("#change_ship_flag").combobox("setValue",value);//可否转船
						}else if(key=="goodsWeight"){
							$("#goods_weight").val(value);//货物毛重
						}else if(key=="latestDateOfShipment"){
							$("#latestDateOfShipment").val(value);//最迟交货期
						}else if(key=="supplyOfGoods"){
							$("#supply_of_goods").combobox("setValue",value);//货源
						}else if(key=="specifiedBox"){
							$("#specified_box").combobox("setValue",value);//是否指定用箱
						}else if(key=="goodsType"){
							$("#goods_type").combobox("setValue",value);//货物种类
						}else if(key=="boxType"){
							$("#box_type").val(value);//箱型确定
						}else if(key=="priceSource"){
							$("#price_source").combobox("setValue",value);//价格来源
						}else if(key=="priceAmount"){
							$("#price_amount").val(value);//船公司订舱价格
						}else if(key=="price_start_date"){
							$("#price_start_date").val(value);//价格开始时间
						}else if(key=="carriageType"){
						     
							$("#carriage_type").combobox("setValue",value);//运费条款
						}else if(key=="feeItem"){
							$("#fee_item").val(value);//其他运费条款
						}else if(key=="priceRemarks"){
							$("#price_remarks").val(value);//价格备注
						}else if(key=="remarks"){
							$("#remarks").val(value);
						}else if(key=="boxTypeHarbor"){
							$("#loadBox1").val(value);
						}else if(key!="salesManName"&&key!="secondSalesMan"&&key!="salesManDep"&&key!="salesManAgent"
								&&key!="secondDep"&&key!="secondCompany"&&key!="secondSalesAgent"){
							if($("#"+key).attr('type')!="checkbox"){
								//$("#"+key).val(value);
							}else{
								if(value=="Y"){
									$("#"+key).attr("checked",true);
									//设置checked选中
									if(key=="isTaoyue"){
										$("#s1").show();
										$("#tr1").show();
										$("#div1").show();
										$("#d1").show();
										$("#d2").show();
									}
								}
							}
							if(key=="box_master" && (value=="MSC"|| value=="msc")){
								$("#tr2").show();
							}
						}
					} catch (e) {
						
					}
					try {
						//likeSelect(value,key);
					} catch (e) {
						
					}
					//设置combogrid的值
					try {
						if("stopHarbour"==key){
							
						}else{
							//$("#"+key).combogrid("setValue",value);
							//$("#"+key).val(value);
						}
					} catch (e) {
						
					}
					//设置cold_rem的值
					try {
						$("#"+key).numberbox("setValue",value);
					} catch (e) {
						
					}
					//设置combobox的值
					try{
						if(key=="salesManDep"){
							$("#salesManDepShow").val(value);//销售人员部门显示
						}else if(key=="departmentId"){
							$("#salesManDep").val(value);//销售人员部门隐藏
						}else if(key=="salesManAgent"){
							$("#salesManAgentShow").val(value);//销售人员公司显示
						}else if(key=="companyCode"){
							$("#salesManAgent").val(value);//销售人员公司隐藏
						}else if(key=="bolType"){
							if(value!=""){
								//$("#"+key).combobox("setValue",value);
							}
						}else if(key=="boxMaster_id"){
							boxMaster_id = value;
						}else if(key=="box_master"){
							$("#box_master").combogrid("setValue",boxMaster_id);
							$("#box_master").combogrid("setText",value);
						}else if(key=="TRANSPORT_CLAUSE_ID"){
							transportItem_id = value;
						}else if(key=="transportItem"){
							$("#transportItem").combogrid("setValue",transportItem_id);
							$("#transportItem").combogrid("setText",value);
						}else if(key=="agencyManId"){
							agencyManId = value;
						}else if(key=="agencyMan"){
							$("#agencyMan").combogrid("setValue",agencyManId);
							$("#agencyMan").combogrid("setText",value)
						}else if(key=="bolType_id"){
							$("#bolType_Id").val(value)
						}else if(key=="CUS_BRO_ID"){
							gateUnitId = value;
						}else if(key=="gateUnit"){
							$("#gateUnit").combogrid("setValue",gateUnitId);
							$("#gateUnit").combogrid("setText",value);
						}else if(key=="PORT_LOADING_ID"){
							portOfLoadingId = value;
						}else if(key=="portOfLoading"){
							$("#portOfLoading").combogrid("setValue",portOfLoadingId);
							$("#protOfLoading").combogrid("setText",value);
						}else if(key=="PLACE_DELIVERY_ID"){
							placeOfDeliveryId = value;
						}else if(key=="placeOfDelivery"){
							$("#placeOfDelivery").combogrid("setValue",placeOfDeliveryId);
							$("#placeOfDelivery").combogrid("setText",value);
						}else if(key=="RIVER_LOAD_ID"){
							loadHarbourId = value;
						}else if(key=="loadHarbour"){
							$("#load_harbour").combogrid("setValue",loadHarbourId);
							$("#load_harbour").combogrid("setText",value);
						}else if(key=="RIVER_UNLOAD_ID"){
							unloadHarbourId = value;
						}else if(key=="unloadHarbour"){
							$("#unload_harbour").combogrid("setValue",unloadHarbourId);
							$("#unload_harbour").combogrid("setText",value);
						}else if(key=="PLACE_DELIVERY_ID"){
							stop_harbourId = value;
						}else if(key=="stop_harbour"){
							$("#stop_harbour").combogrid("setValue",stop_harbourId);
							$("#stop_harbour").combogrid("setText",value);
						}else if(key=="goodsPackage"){
							$("#goods_package").combogrid("setValue",value);
						}else if(key=="TRANSPORT_CLAUSE_ID"){
							transportItemId = value;
						}else if(key=="transportItem"){
							$("#transport_item").combogrid("setValue",transportItemId);
							$("#transport_item").combogrid("setText",value);
						}else{
							//$("#"+key).combobox("setValue",value);
						}
					}catch(e){
						
					}
					///ippc
					if(key=="woodenPacking"&&value=="1"){
						$("#span1").show();
					}
					//判断拖车方式
					if(key=="isTrailer"&&value=="2"){
						$("#trailerInfo").show();
						$("#trailerTr").show();
						$("#trailerShowTab").datagrid("reload",{tradeCode:'JHJCKGWI1814586'});
					}
					//显示箱号
					if(key=="specifiedBox"&&(value=="1"||value=="2")){
						$("#boxNo").show();
						$("#s6").show();
					}
					if(key=="boxLoadType"){
						if(value=="0"){
							$("#loadType0").attr("checked",true);
							$("#loadBox0").show();
							$("#cz").show();
						}else if(value=="1"){
							$("#loadType1").attr("checked",true);
							$("#loadBox1").show();
							$("#tr3").show();
							$("#tr10").show();
							$("#gz").show();
							$("#lbrf").show();
							$("#loadBoxRemark").show();
						}else if(value=="2"){
							$("#loadType0").attr("checked",true);
							$("#loadType1").attr("checked",true);
							$("#loadBox0").show();
							$("#cz").show();
							$("#loadBox1").show();
							$("#tr3").show();
							$("#tr10").show();
							$("#gz").show();
							$("#lbrf").show();
							$("#loadBoxRemark").show();
						}
					}
				});
				/* $("#salesManName").combogrid("setValue",salesManId);
				$("#salesManName").combogrid("setText",salesManName);
				if(""!=salesManId2){
					$("#secondSalesMan").combogrid("setValue",salesManId2);
					$("#secondSalesMan").combogrid("setText",salesManName2);
				} */
			}
		});
	}
	
	
	//提交验证
	function checkSave(){
		//判断销售人员
		var salesManName = $("#salesManName").val();
		if(isBlank(salesManName,"销售人员","salesManName")){
			return false;
		}
		//判断托运人
		var agencyMan = $("#agency_man").val();
		if(isBlank(agencyMan,"托运人","agency_man")){
			return false;
		}
		//判断货主
		var agencyContact = $("#agencyContact").val();
		if(isBlank(agencyContact,"托运人","agencyContact")){
			return false;
		}
		//判断箱主
		var boxMaster = $("#box_master").val();
		if(isBlank(boxMaster,"箱主","box_master")){
			return false;
		}
		//判断贸易类型
		var tradeMode = $("#trade_mode").val();
		if(isBlank(tradeMode,"贸易类型","trade_mode")){
			return false;
		}
		//判断发货人
		var shipper = $("#shipper").val();
		if(isBlank(shipper,"发货人","shipper")){
			return false;
		}
		//判断收货人
		var consignee = $("#consignee").val();
		if(isBlank(consignee,"收货人","consignee")){
			return false;
		}
		//判断通知人
		var noticeMan = $("#notice_man").val();
		if(isBlank(noticeMan,"通知人","notice_man")){
			return false;
		}
		//判断唛头
		var goodsSign = $("#goods_sign").val();
		if(isBlank(goodsSign,"唛头","goods_sign")){
			return false;
		}
		//判断货物描述
		var goodsEnglishName = $("#goods_english_name").val();
		if(isBlank(goodsEnglishName,"货物描述","goods_english_name")){
			return false;
		}
		//判断装运港
		var loadHarbour = $("#load_harbour").val();
		if(isBlank(loadHarbour,"装运港","load_harbour")){
			return false;
		}
		//判断卸货港
		var tradeMode = $("#trade_mode").val();
		var unloadHarbour = $("#unload_harbour").val();
		if(isBlank(unloadHarbour,"卸货港","unload_harbour")){
			return false;
		}
		//判断交货地
		var stopHarbour = $("#stop_harbour").val();
		if(isBlank(stopHarbour,"交货地","stop_harbour")){
			return false;
		}
		//判断中文品名
		var goodsChineseName = $("#goods_chinese_name").val();
		if(isBlank(goodsChineseName,"中文品名","goods_chinese_name")){
			return false;
		}
		//判断货物件数
/* 		var goodsPkgs = $("#goods_pkgs").val();
		if(isBlank(goodsPkgs,"货物件数","goods_pkgs")){
			return false;
		}
		//判断包装
		var goodsPackage = $("#goods_package").val();
		if(isBlank(goodsPackage,"包装及标志","goods_package")){
			return false;
		} */
		//判断货物毛重
		var goodsWeight = $("#goods_weight").val();
		if(isBlank(goodsWeight,"货物毛重","goods_weight")){
			return false;
		}
		//判断体积
/* 		var goodsMeasurment = $("#goods_measurment").val();
		if(isBlank(goodsMeasurment,"体积","goods_measurment")){
			return false;
		} */
		//判断最迟江船装船时间
/* 		var loadDate = $("#load_date").val();
		if(isBlank(loadDate,"最迟江船装船时间","load_date")){
			return false;
		} */
		//判断箱型
		var boxType = $("#box_type").val();
		if(isBlank(boxType,"箱型","box_type")){
			return false;
		}
		//根据货物种类判断
		var goodsType = $("#goods_type").combobox("getValue");
		if(isBlank(goodsType,"货物种类","goods_type")){
			return false;
		}
		//判断冷藏温度
		if("冷藏品"==goodsType||"危险冷藏品"==goodsType){
			var coldRem = $("#cold_rem").numberbox("getValue");
			if(isBlank(coldRem,"冷藏温度","cold_rem")){
				return false;
			}
		}
		//判断危险品信息
		if("危险品"==goodsType||"危险冷藏品"==goodsType){
			var dangerousName = $("#dangerous_name").val();
			if(isBlank(dangerousName,"危险品名","dangerous_name")){
				return false;
			}
		}
		//判断价格开始时间
		var priceAmount = $("#price_amount").val();
		if(isBlank(priceAmount,"船公司订舱价格","price_amount")){
			return false;
		}
		//判断价格开始时间
		var priceStartDate = $("#price_start_date").val();
		if(isBlank(priceStartDate,"价格开始时间","price_start_date")){
			return false;
		}
		//判断价格停止时间
		var priceEndDate = $("#price_end_date").val();
		if(isBlank(priceEndDate,"价格停止时间","price_end_date")){
			return false;
		}
		//判断运输条款
		var transportItem = $("#transport_item").val();
		if(isBlank(transportItem,"运输条款","transport_item")){
			return false;
		}
		//根据付费方式
		var carriageType = $("#carriage_type").combobox("getValue");
		if("FREIGHT COLLECT AT"==carriageType||"FREIGHT PREPAID AT"==carriageType){
			var thirdPlace = $("#third_place").val();
			if(isBlank(thirdPlace,"第三地名称","third_place")){
				return false;
			}
		}
		//判断是否选择装箱方式
		if(!$("#loadType0").is(':checked')&&!$("#loadType1").is(':checked')){
			$.messager.alert("提示","请选择装箱方式","info",function(){
				$('#loadType0').focus();
				$('#loadType0').css("border","1px red solid");
				$('#loadType0').next('span').find('input').focus();
				$("#loadType0").next('span').css("border","1px red solid");
				$('#loadType1').focus();
				$('#loadType1').css("border","1px red solid");
				$('#loadType1').next('span').find('input').focus();
				$("#loadType1").next('span').css("border","1px red solid");
			});
			return false;
		}
		//判断装箱箱型箱量和总的是否一致
		if(!checkBoxType(undefined)){
			return;
		}
		return true;
	}
	//判断是否为空
	function isBlank(str,message,id){
		if(str==''||str==null){
			$.messager.alert("提示",message+"不能为空!","info",function(){
				$('#'+id).focus();
				$('#'+id).css("border","1px red solid");
				$('#'+id).next('span').find('input').focus();
				$("#"+id).next('span').css("border","1px red solid");
			});
			return true;
		}else{
			$('#'+id).css("border","1px #95B8E7 solid");
			$("#"+id).next().css("border","1px #95B8E7 solid");
		}
		return false;
	}
	//判断是否为空
	function isBlan(str){
		if(str==''||str==null){
			return true;
		}
		return false;
	}
	//获取当前登录用户ID
	function getUserId(){
		$.ajax({
			type:"POST",
			//url:"getUserId.do",
			dataType:"json",
			success:function(data){
				$.each(data,function(key,value){
					$("#userId").val(data.userId);
				});
			}
		});
	}
	//获取当前时间
	function getNowTime(id){
		$.ajax({
			type:"POST",
			url:"consignMgr/getCurrentTime.do",
			dataType:"json",
			success:function(data){
				$.each(data,function(key,value){
					$("#"+id).val(value);
				});
			}
		});
	}
	
	//销售人员
	function salesManName(){
		var department = $('#salesManName').combogrid("grid").datagrid("getSelected").department;
		var name = $('#salesManName').combogrid("grid").datagrid("getSelected").name_;
		var id_ = $('#salesManName').combogrid("grid").datagrid("getSelected").id_;
		var departmentid = $('#salesManName').combogrid("grid").datagrid("getSelected").departmentid;
		var companyName = $('#salesManName').combogrid("grid").datagrid("getSelected").company_name;
		var companyCode = $('#salesManName').combogrid("grid").datagrid("getSelected").company_code;
		$("#salesManName").combogrid("setValue",id_+"name");
		$("#salesManName").combogrid("setText",name);
		$("#sales_man_dep").val(departmentid+"@"+department);
		$("#sales_man_dep_show").val(department);
		$("#sales_man_agent").val(companyCode+"@"+companyName);
		$("#sales_man_agent_show").val(companyName);
		$("#salesManName").val(id_);     
	}
	//托运人全称
	function agencyMan(){
		var flag = $("#agency_man").combogrid("grid").datagrid("getSelected").ac;
		var customerName = $("#agency_man").combogrid("grid").datagrid("getSelected").customer_name;
		var contact = $("#agency_man").combogrid("grid").datagrid("getSelected").work_man;
		var contactInfo = $("#agency_man").combogrid("grid").datagrid("getSelected").work_phone;
		var customerType = $("#agency_man").combogrid("grid").datagrid("getSelected").customer_type;
		var nmAccountType = $("#agency_man").combogrid("grid").datagrid("getSelected").nm_account_type;
		if(judgeCustomer("agency_man",flag)){
			$('#agency_man').combogrid("setValue",customerName);
			$('#agencyContact').combogrid("setValue",customerName);
			$('#agency_man').val(customerName);
			$('#agencyContact').val(customerName);
			$('#pay_way').val(nmAccountType);
			$('#client_type').val(customerType);
			$('#contact').val(contact);
			$('#contact_info').val(contactInfo);
		}
	}
	//货主
	function agencyContact(){
		var flag = $("#agencyContact").combogrid("grid").datagrid("getSelected").ac;
		var customerName = $("#agencyContact").combogrid("grid").datagrid("getSelected").customer_name;
		if("合同已到期"==flag){
			$.messager.alert("提示","该客户合同已到期!","info");
			$('#agencyContact').combogrid("clear");
			return;
		}
		$("#agencyContact").val(customerName);
		$("#agencyContact").combogrid("setText",customerName);
		$("#agencyContact").combogrid("setValue",customerName);
	}
	//箱主
	function boxMaster(){
		var cqCode = $("#box_master").combogrid("grid").datagrid("getSelected").cq_code;
		var remrk = $("#box_master").combogrid("grid").datagrid("getSelected").remrk;
		var id = $("#box_master").combogrid("grid").datagrid("getSelected").id_;
		$('#box_master').combogrid("setValue",id+"@"+cqCode);
		$("#box_master").combogrid("setText",cqCode);
		$("#box_master").val(cqCode);
	}
	//发货人
	function searchShipper(){
		var consigneeName = $("#search_shipper").combogrid("grid").datagrid("getSelected").consignee_name;
		var spellCode = $("#search_shipper").combogrid("grid").datagrid("getSelected").spell_code;
		$('#search_shipper').combogrid("setValue",spellCode);
		$("#shipper").val(consigneeName);
	}
	//收货人
	function searchConsignee(){
		var consigneeName = $("#search_consignee").combogrid("grid").datagrid("getSelected").consignee_name;
		var spellCode = $("#search_consignee").combogrid("grid").datagrid("getSelected").spell_code;
		$('#search_consignee').combogrid("setValue",spellCode);
		$("#consignee").val(consigneeName);
	}
	//通知人
	function searchNoticeMan(){
		var consigneeName = $("#search_notice_man").combogrid("grid").datagrid("getSelected").consignee_name;
		var spellCode = $("#search_notice_man").combogrid("grid").datagrid("getSelected").spell_code;
		$('#search_notice_man').combogrid("setValue",spellCode);
		$("#noticeMan").val(consigneeName);
	}
	//装运港
	function loadHarbour(){
		var harbourName = $("#load_harbour").combogrid("grid").datagrid("getSelected").harbour_name;
		var englishName = $("#load_harbour").combogrid("grid").datagrid("getSelected").english_name;
		var mileage = $("#load_harbour").combogrid("grid").datagrid("getSelected").mileage;
		var id = $("load_harbour").combogrid("grid").datagrid("getSelected").id_;
		$('#load_harbour').combogrid("setValue",id+"@"+harbourName);
		$('#load_harbour').combogrid("setText",harbourName);
		$("#load_harbour").val(harbourName);
		$("#load_harbour_milage").val(mileage);
	}
	//卸货港
	function unloadHarbour(){
		var harbourName = $("#unload_harbour").combogrid("grid").datagrid("getSelected").harbour_name;
		var englishName = $("#unload_harbour").combogrid("grid").datagrid("getSelected").english_name;
		var mileage = $("#unload_harbour").combogrid("grid").datagrid("getSelected").mileage;
		var id = $("#unload_harbour").combogrid("grid").datagrid("getSelected").id_;
		$('#unload_harbour').combogrid("setValue",id+"@"+harbourName);
		$("#unload_harbour").combogrid("setText",harbourName);
		$("#unload_harbour").val(harbourName);
		$("#unload_harbour_milage").val(mileage);
	}
	//交货地
	function stopHarbour(){
		var harbourName = $("#stop_harbour").combogrid("grid").datagrid("getSelected").harbour_name;
		$('#stop_harbour').combogrid("setValue",harbourName);
		$("#stop_harbour").val(harbourName);
	}
	//货物包装方式
	function goodsPackage(){
		var packaging = $("#goods_package").combogrid("grid").datagrid("getSelected").packaging;
		$('#goods_package').val(packaging);
		$('#goods_package').combogrid("setValue",packaging);
	}
	//港装包装
	function harbourPackage(){
		var packaging = $("#harbour_package").combogrid("grid").datagrid("getSelected").packaging;
		$('#harbour_package').val(packaging);
		$('#harbour_package').combogrid("setValue",packaging);
	}
	//危险品名
	function dangerousName(){
		var dangerousName = $("#dangerous_name").combogrid("grid").datagrid("getSelected").dangerous_name;
		var mainLevel = $("#dangerous_name").combogrid("grid").datagrid("getSelected").main_level;
		var dangerousType = $("#dangerous_name").combogrid("grid").datagrid("getSelected").dangerous_type;
		var internalCode = $("#dangerous_name").combogrid("grid").datagrid("getSelected").internal_code;
		var internationalCode = $("#dangerous_name").combogrid("grid").datagrid("getSelected").international_code;
		$('#dangerous_name').val(dangerousName);
		$("#dangerous_type").val(dangerousType);
		$("#dangerous_level").val(mainLevel);
		$("#internal_code").val(internalCode);
		$("#international_code").val(internationalCode);
		$('#dangerous_name').combogrid("setValue",dangerousName);
	}
	//运输条款
	function transportItem(){
		var transportItem = $("#transport_item").combogrid("grid").datagrid("getSelected").transport_item;
		var id = $("#transport_item").combogrid("grid").datagrid("getSelected").id_;
		$('#transport_item').combogrid("setValue",id+"@"+transportItem);
		$("#transport_item").combogrid("setText",transportItem);
		$("#transport_item").val(transportItem);
	}
	
	//按Enter键选择唯一行
	function pressEnter(id){
		var pClosed = $("#"+id).combogrid("panel").panel("options").closed;
        if(!pClosed){
            $("#"+id).combogrid("hidePanel");
        }
        var record = $("#"+id).combogrid("grid").datagrid("getRows");
        if(record==null || record == undefined){
        	return null;
        }else {
            if(record.length==1){
            	return record;
            }else{
            	return null;
            }
        }
	}
	//按上方向键移动选择行
	function pressUp(id){
        var pClosed = $("#"+id).combogrid("panel").panel("options").closed;
        if(pClosed){
            $("#"+id).combogrid("showPanel");
        }
        var grid = $("#"+id).combogrid("grid");
        var rowSelected = grid.datagrid("getSelected");
        if(rowSelected!=null){
            var rowIndex = grid.datagrid("getRowIndex", rowSelected);
            if(rowIndex > 0){
                rowIndex = rowIndex - 1;
                grid.datagrid("selectRow", rowIndex);
            }
        }else if(grid.datagrid("getRows").length > 0){
            grid.datagrid("selectRow", 0);
        }

	}
	//按下方向键移动选择行
	function pressDown(id){
		var pClosed = $("#"+id).combogrid("panel").panel("options").closed;
        if(pClosed){
            $("#"+id).combogrid("showPanel");
        }
        var grid = $("#"+id).combogrid("grid");
        var rowSelected = grid.datagrid("getSelected");
        if(rowSelected != null){
            var totalRow = grid.datagrid("getRows").length;
            var rowIndex = grid.datagrid("getRowIndex", rowSelected);
            if(rowIndex < totalRow - 1){
                rowIndex = rowIndex + 1;
                grid.datagrid("selectRow", rowIndex);
            }
        }else if(grid.datagrid("getRows").length > 0){
            grid.datagrid("selectRow", 0);
        }
	}
	//datagrid的 统一模糊查询
	function likeSelect(keyword,id){
		//动态搜索  
		$('#'+id).combogrid("grid").datagrid("reload",{'keyword':keyword,'tradeFlag':1});
		$('#'+id).combogrid("setValue",keyword);
		$('#'+id).val("");
		$('#'+id).combogrid("grid").datagrid("reload");
	}
	//光标离开时判断客户状态
	function judgeCustomer(id,flag){
		if("合同已到期"==flag){
			$.messager.alert("提示","该客户合同已到期!","info",function(){
				$('#'+id).next('span').find('input').focus();
			});
			$('#'+id).combogrid("clear");
			if(id=="agency_man"){
				$('#agencyContact').combogrid("clear");
			}
			return false;
		}else{
			if(flag.indexOf("客户还有")!=-1){
				$.messager.alert("提示",flag,"info",function(){
					$('#'+id).next('span').find('input').focus();
				});
			}
		}
		return true;
	}
	//设定弹出框位置
	function autoLocation(id,height){
		//获取浏览器显示区域的高度   
		$(window).height();   
		//获取浏览器显示区域的宽度   
		$(window).width();   
		//获取页面的文档高度   
		$(document.body).height();   
		//获取页面的文档宽度   
		$(document.body).width();   
		//获取滚动条到顶部的垂直高度   
		$(document).scrollTop();   
		//获取滚动条到左边的垂直宽度   
		$(document).scrollLeft();
		$("#"+id).dialog("move",{top:$(document).scrollTop() + ($(window).height()-height) * 0.5});
	}
	//计算装箱方式中的箱型箱量
	function calculateBox(element){
		//获取总的箱型箱量
		var boxTypeTotal=$("#box_type").val();
		var boxTypeTotals=null;
		if(""!=boxTypeTotal){
			boxTypeTotals=boxTypeTotal.split("&&");
		}
		//离开装箱方式箱型输入框时先分配两个输入框的箱型箱量再进行判断比较
		var bt = element.value;
		var bts = null;
		if(""!=bt){
			bts = bt.split("&&");
		}
		//将当前元素的箱型箱量放入Map集合中
		var thisType={};
		var length=0;
		if(bts!=null){
			for(var i=0;i<bts.length;i++){
				var num=bts[i].split("X")[0];
				var type=bts[i].split("X")[1];
				if(thisType[type]==undefined){
					thisType[type]=Number(num);
					length=length+1;
				}else{
					thisType[type]=thisType[type]+Number(num);
				}
			}
		}
		//判断如果存在两种装箱方式则自动计算箱型箱量
		if($("#loadType0").is(':checked')&&$("#loadType1").is(':checked')){
			var val = "";
			for(var i=0;i<boxTypeTotals.length;i++){
				var num=boxTypeTotals[i].split("X")[0];
				var type=boxTypeTotals[i].split("X")[1];
				if(thisType[type]==undefined){
					val += num+"X"+type+"&&";
				}else{
					if(Number(num)-thisType[type]>0){
						val += (Number(num)-thisType[type])+"X"+type+"&&";
					}
				}
			}
			if(val!=""){
				val = val.substring(0,val.length-2);
			}
			if(element.id=="box_type_factory"){
				$("#box_type_harbor").val(val);
			}else if(element.id=="box_type_harbor"){
				$("#box_type_factory").val(val);
			}
		}
	}
	//判断装箱方式中的箱型箱量和总的是否一致
	function checkBoxType(element){
		//获取总的箱型箱量
		var boxTypeTotal=$("#box_type").val();
		var boxTypeTotals=null;
		if(""!=boxTypeTotal){
			boxTypeTotals=boxTypeTotal.split("&&");
		}
		//计算箱型箱量
		if(undefined!=element){
			calculateBox(element);
		}
		//获取装箱方式中的箱型箱量
		var boxTypeCz=$("#box_type_factory").val();
		var boxTypeCzs=null
		if(""!=boxTypeCz){
			boxTypeCzs=boxTypeCz.split("&&");
		}
		var boxTypeGz=$("#box_type_harbor").val();
		var boxTypeGzs=null;
		if(""!=boxTypeGz){
			boxTypeGzs=boxTypeGz.split("&&");
		}
		if(boxTypeCz==""&&boxTypeGz==""){
			$.messager.alert("警告","装箱方式中的箱型箱量与总箱型箱量不匹配!","warning");
			return false;
		}
		if(boxTypeTotal==""&&(boxTypeCz!=""||boxTypeGz!="")){
			$.messager.alert("警告","装箱方式中的箱型箱量与总箱型箱量不匹配!","warning");
			return false;
		}
		//将装箱方式中的箱型箱量存到类Map集合中去
		var hasType={};
		var length=0;
		if(boxTypeCzs!=null){
			for(var i=0;i<boxTypeCzs.length;i++){
				var num=boxTypeCzs[i].split("X")[0];
				var type=boxTypeCzs[i].split("X")[1];
				if(hasType[type]==undefined){
					hasType[type]=Number(num);
					length=length+1;
				}else{
					hasType[type]=hasType[type]+Number(num);
				}
			}
		}
		if(boxTypeGzs!=null){
			for(var i=0;i<boxTypeGzs.length;i++){
				var num=boxTypeGzs[i].split("X")[0];
				var type=boxTypeGzs[i].split("X")[1];
				if(hasType[type]==undefined){
					hasType[type]=Number(num);
					length=length+1;
				}else{
					hasType[type]=hasType[type]+Number(num);
				}
			}
		}
		if(length!=boxTypeTotals.length){
			$.messager.alert("警告","装箱方式中的箱型箱量与总箱型箱量不匹配!","warning");
			return false;
		}
		for(var i=0;i<boxTypeTotals.length;i++){
			var num=boxTypeTotals[i].split("X")[0];
			var type=boxTypeTotals[i].split("X")[1];
			if(hasType[type]==undefined){
				$.messager.alert("警告","装箱方式中的箱型箱量与总箱型箱量不匹配!","warning");
				return false;
			}else{
				if(hasType[type]!=Number(num)){
					$.messager.alert("警告","装箱方式中的箱型箱量与总箱型箱量不匹配!","warning");	
					return false;
				}
			}
		}
		return true;
	}
</script>

</html>